python - How to compare 2 csv files with > 1000 rows and find the difference? -


i have python script scrapes website , downloads data in csv file.

i run script weekly. want compare 2 weeks csv , find row has been changed in these 2 csv.

the data in csv 98% same 1 or 2 rows either gets added or deleted.

i not able proper solution. used dictreader , tried compare content no success.

any pointers solve might help, read can convert these set , seta - setb

if helps give format of how csv are.

file1.csv

name,userid,location aaa,abc,nyc bbb,cdf,ucl 

file2.csv

name,userid,location bbb,cdf,ucl 

now if see, 1 row deleted in file2.csv, when compare file1.csv , file2.csv should able value aaa,abc,nyc

yes, set difference works.

with open('file1.csv') f, open('file2.csv') g:     old, new = set(f), set(g) added in new - old:     print('added', added) deleted in old - new:     print('deleted', deleted) 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -