(I’m quite new to python, so if you notice any mistake feel free to point it out)
So I am trying to make an application with csv, and I’m trying to load the content of a csv, however I have a list in my csv, which is made into a string and I can’t seem to get it back to a list.
Notes = list(csv.DictReader(open("Notes.csv", "r"), delimiter = ";"))
print(Notes)
Output:
[{'USER_ID': 1, '1': '[(14,2)]', '2': 0, '3': 0, '4': 0, '5': 0, '6': 0, '7': 0, '8': 0, '9': 0, '10': 0, '11': 0, '12': 0, '13': 0, '14': 0, '15': 0, '16': 0, '17': 0, '18': 0, '19': 0, '20': 0, '21': 0, '22': 0, '23': 0, '24': 0}, {'USER_ID': 2, '1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0, '7': 0, '8': 0, '9': 0, '10': 0, '11': 0, '12': 0, '13': 0, '14': 0, '15': 0, '16': 0, '17': 0, '18': 0, '19': 0, '20': 0, '21': 0, '22': 0, '23': 0, '24': 0}, {'USER_ID': 3, '1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0, '7': 0, '8': 0, '9': 0, '10': 0, '11': 0, '12': 0, '13': 0, '14': 0, '15': 0, '16': 0, '17': 0, '18': 0, '19': 0, '20': 0, '21': 0, '22': 0, '23': 0, '24': 0}]
(the 0 are here just to fill in don’t pay attention to it)
I tried to strip and split, but it ended up being a list with a string inside (string being the tuple in the list) I also tried to get the simply the numbers inside the string and remake the list with the tuple and numbers inside, but if there is more than one tuple in the list this won’t work.
Martin Student VALAT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.