[gdal-dev] OGR CSV oddity

Scott public at postholer.com
Sat Jun 17 09:00:48 PDT 2023


Weird. Thanks Even!

On 6/17/23 08:58, Even Rouault wrote:
> 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
>>


More information about the gdal-dev mailing list