duckdb icon indicating copy to clipboard operation
duckdb copied to clipboard

[CLI] import of quotes values where the first column name is missing.

Open alexhallam opened this issue 2 years ago • 1 comments

What happens?

import fails on specific csv

To Reproduce

Example csv file band_members.csv

"","name","band"
"1","Mick","Stones"
"2","John","Beatles"
"3","Paul","Beatles"
duckdb csv.db
D .import data/band_members.csv band_members --csv
data/band_members.csv:1: expected 1 columns but found 3 - extras ignored
data/band_members.csv:2: expected 1 columns but found 3 - extras ignored
data/band_members.csv:3: expected 1 columns but found 3 - extras ignored
data/band_members.csv:4: expected 1 columns but found 3 - extras ignored
D select * from band_members;
┌────────────────────┐
│   ","name","band   │
├────────────────────┤
│ 1","Mick","Stones  │
│ 2","John","Beatles │
│ 3","Paul","Beatles │
│                    │
│ 1                  │
│ 2                  │
│ 3                  │
└────────────────────┘

Environment (please complete the following information):

  • OS: (e.g. iOS): ubuntu
  • DuckDB Version:
duckdb --version
v0.4.0 da9ee490d

Identity Disclosure:

  • Full Name: alexhallam
  • Affiliation: None

Before Submitting

Strictly CLI API only.

alexhallam avatar Jul 13 '22 03:07 alexhallam

. import uses the shells' built-in CSV reader, which comes from SQLite. It seems to fail because a column name is empty:

CREATE TABLE band_members(...) failed: Parser Error: zero-length delimited identifier at or near """"
LINE 2:   "" TEXT,

This works in SQLite because SQLite supports empty column names in tables.

Perhaps we should switch the .import to use DuckDB's own CSV reader in the first place.

Mytherin avatar Jul 13 '22 06:07 Mytherin

In a sense, this is a dup of #1603.

omo avatar May 11 '23 04:05 omo

Also facing this issue @onefact with @stockdaleb108

jaanli avatar Jul 19 '23 14:07 jaanli

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Oct 18 '23 00:10 github-actions[bot]

This issue was closed because it has been stale for 30 days with no activity.

github-actions[bot] avatar Nov 18 '23 00:11 github-actions[bot]