I have a file comprising five columns seperated by commas, i.e.,
g,1,2,3,4
c,4,2,6,8
d,5,6,8,9
I wish to read this file to a dictionary such that column 1 is the key and columns 2-4 are the integer values, i.e.,
d = {"g":[1, 2, 3, 4], "c":[4, 2, 6, 8], ...etc}
I've been playing around with a code snippet i found on the internet, but it returns a ValueError: too many values to unpack (expected 2)
d = {}
with open("file.csv") as f:
for line in f:
(key, val) = line.split(",")
d[key] = int(val)