[gdal-dev] OGR CSV oddity

Even Rouault even.rouault at spatialys.com
Sat Jun 17 08:58:15 PDT 2023


yep, known oddity. Presumably out of caution, the CSV driver refused for 
years to open a CSV with a single column, so on the writing side, it 
adds this dummy comma. Since recently (3.7.0 I believe), the read side 
of the CSV accepts single column header without trailing comma, but the 
write side still generates one

Le 17/06/2023 à 17:54, Scott a écrit :
> If I select a single column from a table, the header column name has a 
> trailing comma. If I select more than 1 column it does not. Example:
>
> ogr2ogr -f CSV -sql "select col1 from table limit 1" /vsistdout/ 
> source.gpkg
>
> Output:
>
> col1,
> 123
>
> Tested on 3.5.1 and 3.7
>
> I've tried this on various column data types with the same result.
>
> Pseudo suggestion:
> header += header.length ? "," + colname : colname
>
-- 
http://www.spatialys.com
My software is free, but my time generally not.



More information about the gdal-dev mailing list