Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ogr2ogr will not recognise a CSV file unless it has at least one delimiter in header. #7595

Closed
marklit opened this issue Apr 14, 2023 · 1 comment
Assignees

Comments

@marklit
Copy link

marklit commented Apr 14, 2023

This was run on Ubuntu 20 LTS, PostgreSQL 15, PostGIS 3.2.1.

$ ~/duckdb_spatial/build/release/duckdb \
      -unsigned \
      census.duckdb
COPY (SELECT wkb_geometry WKT
      FROM census_2010
      ORDER BY LENGTH(wkb_geometry::text) DESC
      LIMIT 1)
TO 'out.csv' WITH (HEADER 1);
$ head -c40 out.csv 
WKT
"POLYGON ((-89.859552 30.004109, -89
$ ogr2ogr \
    -f GPKG \
    out.gpkg \
    CSV:out.csv \
    -a_srs EPSG:4326
FAILURE:
Unable to open datasource `CSV:out.csv' with the following drivers.
...
  -> `CSV'

I have to add a delimiter to the first line of the file before ogr2ogr will open it properly.

$ sed -i '1 s|$|,|' out.csv
$ ogr2ogr \
    -f GPKG \
    out.gpkg \
    CSV:out.csv \
    -a_srs EPSG:4326
@rouault rouault self-assigned this Apr 14, 2023
rouault added a commit that referenced this issue Apr 20, 2023
CSV: allow reading single column file (fixes #7595)
@marklit
Copy link
Author

marklit commented Apr 20, 2023

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants