Guest User

Untitled

a guest
Jul 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. import csv
  2.  
  3. with open('test.csv', 'r') as csvfile:
  4. csv_obj = csv.reader(csvfile, delimiter=',')
  5. cols = list(set([row[0] for i,row in enumerate(csv_obj) if i != 0]))
  6. csvfile.seek(0)
  7. csv_file_list = [row for row in csv_obj]
  8. d = { cols[i]: [row[1:len(row)] for row in csv_file_list if row[0] == cols[i]] for i in range(len(cols))}
  9. print(d)
Add Comment
Please, Sign In to add comment