it’s really frustrating: I just stored some data rows containing lists after a long long calculation in a csv file.
I am unable to get the csv data back into variable.
Its more precise a row like
pete; [1,2,3,4,5]; [(1,2),(3,4),(5,6),…]
Sure, Python csv parses to a string :/,
thus, if I try the list()-casting, it’s like:
list("[(1,2),(3,4)]") = ['[','(','1',',',...]
Do you have any idea to cope with this?
thought I could use:
for name,list,lTuples in csvfile:
…
Thanks a lot!
You can use ast.literal_eval (as long as the string contains only strings, numbers, tuples, lists, dicts, booleans, and None).