based on this
if you are certain you don't have header row then this would also do
for idx,row in enumerate(csv_data): if not idx:#skip header if any continueyou have header row or if not then you omit the first row by mistake. In any case if idx==0 you don't process that line
if you are certain you don't have header row then this would also do
# DB data sql = """SELECT DISTINCT NODE FROM ansible_hosts_view;""" c2.execute(sql) lresult = {item[0] for item in c2.fetchall()} # already set object # csv data csv_reader = unicodecsv.reader(file('ansible_load_file.txt'), encoding='utf-8') csv_hosts_nim = {row[0] for row in csv_reader} # change 'id' to whatever respective column header is #difference diff_to_del = list(lresult.difference(csv_hosts_nim))
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs