Guest User

Untitled

a guest
Jan 17th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. sachin,88
  2. sehwag,98
  3. sachin,89
  4. dhoni,68
  5. virat,98
  6. dhoni,67
  7.  
  8. sachin,99
  9. sehwag,98
  10. dhoni,78
  11. virat,89
  12. virat,25
  13.  
  14. 2 records found for sachin in input1.csv
  15. 1 record found for sachin in input2.csv
  16.  
  17. 2 records found for dhoni in input1.csv
  18. 1 record found for dhoni in input2.csv
  19.  
  20. 1 record found for virat in input1.csv
  21. 2 records found for virat in input2.csv
  22.  
  23. import csv
  24.  
  25. f = csv.reader(open('infile.csv','rb'))
  26. writer = csv.writer(open('outfile.csv','wb'))
  27. names= set()
  28.  
  29. i tried with something like below , but it dint work
  30. # count all the emails before we write anything out
  31. names = Counter()
  32. for row in f:
  33. names+=Counter([row[0]])
  34.  
  35. # now write the file
  36. for row in names.items():
  37. writer.writerow(row)
Add Comment
Please, Sign In to add comment