jimmyH / mypois

Build POIs for Skoda MIB2 (Columbus & Amundsen) SatNavs
GNU General Public License v2.0
20 stars 5 forks source link

fix: Python parse CSV ignoring comma with double-quotes #9

Open 1e1 opened 6 years ago

1e1 commented 6 years ago

I had an issue with:

BUILD_csv_h/GATSO_ALL_h.csv:40463:3.82251,43.631954,"max @50","GRABELS vers JUVIGNAC \"Avenue de l'Europe, face \"\"Les Milles et une Choses\""

and:

BUILD_csv_h/GATSO_ALL_h.csv:40463:3.82251,43.631954,"max @50","GRABELS vers JUVIGNAC \"Avenue de l'Europe\, face \"\"Les Milles et une Choses\""

I found the fix on: https://stackoverflow.com/questions/21527057/python-parse-csv-ignoring-comma-with-double-quotes

jimmyH commented 6 years ago

Looks good. I just want to create some test cases to check it doesn't break parsing any other csv files before I merge it.

jimmyH commented 6 years ago

Actually, looks like your data has 4 columns:

3.82251,43.631954,"max @50","GRABELS vers JUVIGNAC \"Avenue de l'Europe\, face \"\"Les Milles et une Choses\""

Column3 = max@50 Column4 = GRABELS vers JUVIGNAC "Avenue de l'Europe, face ""Les Milles et une Choses" (adding escapechar='\' to read_csv() we can remove the escape characters)

1e1 commented 6 years ago

Yep! But i'm using a CSV with header. My first line give names: longitude, latitude, name, comment. It works fine ;) I think we can see the comments if we load the POI by Car-Net.

jimmyH commented 6 years ago

We will currently ignore the 4th column. There isn't a separate field in the database to store the comment (or display it on the satnav). So how would you want the code to handle the 'comment' field? We could just concatenate name & comment.

1e1 commented 6 years ago

It is not the issue. The parser failed because it parse the coma between double quotes. It counts 5 fields for this line. But it is initialized with 4 columns.

I thought I have seen a description for embed POI. Perhaps it is Car-Net service. I have seen a description for embed POI. Or we should test pPoiSystemTable.personalComment?

jimmyH commented 6 years ago

The parser fails because of the escape (\) characters (fixed in 4c7e9493)

pPoiSystemTable.personalComment is used for each category, not for each POI.

1e1 commented 6 years ago

Thanks for the update! We can discuss about pPoiSystemTable.personalComment in the "documentation" thread: https://github.com/jimmyH/mypois/issues/10