My INPUT file:
1,boss,30
2,go,35
2,nan,45
3,fog,33
4,kd,55
4,gh,56
Output file should be:
1,boss,30
3,fog,33
Means my output file should be free from duplicates. I should delete the record which is repeating based on the column 1.
Code I tried:
source_rd = csv.writer(open("Non_duplicate_source.csv", "wb"),delimiter=d)
gok = set()
for rowdups in sort_src:
if rowdups[0] not in gok:
source_rd.writerow(rowdups)
gok.add( rowdups[0])
Output I got:
1,boss,30
2,go,35
3,fog,33
4,kd,55
What am I doing wrong?