Hi everyone,
I would like to save a list (with nested list inside) to a CSV
the problem is that the nested list are quoted with " sign in the csv file.
and when I read back the file the nested list are no longer lists but string :/
any ideas to solve this problem ?
I would like to save a list (with nested list inside) to a CSV
the problem is that the nested list are quoted with " sign in the csv file.
and when I read back the file the nested list are no longer lists but string :/
any ideas to solve this problem ?
import csv y = [1,10] data = [ ['John','Doe',y], ['Gordon','Freeman',[5,20]], ['Lara','Croft',[7,35]], ] print(data[0][2]) #give [1,10] print(len(data[1][2])) #give 2 <------ with open('28_test.csv', 'w', newline='') as output: writer = csv.writer(output) writer.writerows(data) readback = [] with open('28_test.csv', 'r') as readed: reader = csv.reader(readed) readback = list(reader) print('data:',data) print('readback:',readback) print(readback[0][2]) #give [1,10] print(len(readback[1][2])) #give 7 <------