Hello everyone,
I have a csv file, but I get an error below row while importing it.
Project | Hospital date | Reception date | Culture | Sample type | Status | Box | Last_extraction_date | Inactivation_date | Transfer_date | Comments | Lib | run_pal | Run_id_miseq |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Orizaba | 2004-02-25 | 2022-07-04 | MGIT | Sequenced | 2023-03-24 | 2023-03-23 | 2023-04-06 | No existe este tubo, hay uno con num 711000 | LIB23-015Hflex_1/4 | run308_PAL23-025 | X204SC23092758-Z01-F001 |
The problem is ‘comma’:
‘No existe este tubo, hay uno con num 711000’
items = csv.reader(fp, skipinitialspace=True, quotechar='"')
Output:
[‘Orizaba;2004-02-25;2022-07-04;MGIT;;Sequenced;;2023-03-24;2023-03-23;2023-04-06;No existe este tubo’, ‘hay uno con num 711000;LIB23-015Hflex_1/4;run308_PAL23-025;X204SC23092758-Z01-F001’]
It puts an apostrophe before a comma and a space. That’s why an error occurs after the text “No existe este tubo”. Do you know how to fix the issue? I’m stuck here.
And I loop items here.
listItem = item.split(";")
Output:
[‘Orizaba’, ‘INSTITUTO NACIONAL DE CIENCIAS MEDICAS Y NUTRICION SALVADOR ZUBIRAN INCMNSZ’, ‘No’, ‘2004-02-25’, ‘2022-07-04’, ‘MGIT’, ‘’, ‘Sequenced’, ‘’, ‘2023-03-24’, ‘2023-03-23’, ‘2023-04-06’, ‘No existe este tubo’]