[gdal-dev] CSV driver inconsistent separator dealing to failures

Moises Calzado mcalzado at carto.com
Tue May 23 06:43:38 PDT 2023


Hello everyone,

I'm trying to use ogr2ogr with a CSV file that uses semicolons as
separator, but there is a field that contain one comma. The issue that I'm
facing is that as it contains a comma, it originally takes the comma as
separator, so it's not parsed correctly.

However, when trying to open the CSV file with another application it works
like a charm, as the separator is correctly identified.

I've been having a look at the function that identifies the separator, and
it seems that if it finds two possible separators, it takes the comma as
the right one. To double-check that, I executed the command in debug mode,
and the following warning was shown:

CSV: Inconsistent separator. ';' and ',' found. Using ',' as default


In my humble opinion it makes sense to follow this approach if the
separator is not clear, but in this case the first CSV line contains
like 10 semicolons (the real separator) and just one comma. I believe that
the actual behaviour could be improved adding some way of checking the most
repeated separator. What do you think?

-- 
*Moises Calzado*

Support Engineer

+34671264286 | mcalzado at carto.com | CARTO <https://www.carto.com/>
<https://spatial-data-science-conference.com/2023/london/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20230523/f8cffb6b/attachment.htm>


More information about the gdal-dev mailing list