My CSV file looks like this:
id,name,list
1,Beans,[1,2,3]
2,Spam,[5,6,7]
5,Spam,[7,8,9]
When I try to read the last column using the following code:
with open('some.csv', newline='') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
print(row["list"])
the output i get is:
[1
[5
[7
Apparently, it separates the list at the first ','. However i want it to read the whole list as one column. So my expected output is:
[1,2,3]
[5,6,7]
[7,8,9]
I plan to store each of these in variables so they can be used as I'd use a normal list to iterate over it or perform other tasks.
How do i achieve this?