Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- with open('test.csv', 'r') as csvfile:
- csv_obj = csv.reader(csvfile, delimiter=',')
- cols = list(set([row[0] for i,row in enumerate(csv_obj) if i != 0]))
- csvfile.seek(0)
- csv_file_list = [row for row in csv_obj]
- d = { cols[i]: [row[1:len(row)] for row in csv_file_list if row[0] == cols[i]] for i in range(len(cols))}
- print(d)
Add Comment
Please, Sign In to add comment