duckdb / duckdb/duckdb-spatial
Reading TXT file as CSV with ST_Read()
- Dominant language
- C
- Stars
- 708
- Forks
- 96
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 5
Description
I am trying to use st_read to read a *.txt as a CSV without needing to rename the file.
This works fine:
SELECT * FROM st_read('CarrisMetropolitana/stops.csv', allowed_drivers=['CSV']);
But the original file as a txt extension, so this fails
select * from st_read('CarrisMetropolitana/stops.txt',allowed_drivers=['CSV']);
IO Error: GDAL Error (4): `CarrisMetropolitana/stops.txt' not recognized as a supported file format.
Of course I can just rename all files, but what I really wanted to do is read it directly from a compressed GTFS zip file, which fails:
SELECT * FROM st_read('/vsizip/CarrisMetropolitana.zip/stops.txt', allowed_drivers=['CSV']);
But if inside the ziz there's a the same file as with csv extentionit works pretty well.
SELECT * FROM st_read('/vsizip/CarrisMetropolitana.zip/stops.csv', allowed_drivers=['CSV']);
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing the st_read entry point and how allowed_drivers is passed to GDAL, comparing direct paths with /vsizip paths. Done means a CSV-formatted .txt file can be read without renaming it, including from the compressed GTFS zip example, while the existing .csv behavior remains working.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100