I am working with Python 2.7 under Ubuntu 18.04 and I am treating some datas from a .csv file. In order to pass them in my script, I need to have them in a list in a specific format. Here is what it should look like:
data = [('15', '10', '11', '17'),
('18', '18', '17', '18'),
('12', '17', '17', '18'),
('14', '12', '17', '14'),
('15', '11', '19', '17')]
each "value" contained in the .csv file is a serie of numbers surrounded by () like that "('15', '10', '11', '17')".
my .csv file looks like that:
('15', '10', '11', '17');
('18', '18', '17', '18');
('12', '17', '17', '18');
('14', '12', '17', '14');
('15', '11', '19', '17')
and the script reading the csv file is this one :
import csv
data = []
with open('logsTESTII.csv', 'r') as f:
reader = csv.reader(f, delimiter = ';')
for row in reader:
data.append(list(reader))
print (data)
no matter what I do, I tried many variation of this script or .csv file structure, I always get weird results like that:
[[["('18', '18', '17', '18')", ''], ["('12', '17', '17', '18')", ''], ["('14', '12', '17', '14')", ''], ["('15', '11', '19', '17')"], [], []]]
I just need a list with all my datas , one after the other separated by a comma.
How could I proceed ? Please, this is driving me insane.
Thanks in advance, Pixelle