Is there a way to assign --no-header parameter?
kathe-ruiz opened this issue · 1 comments
kathe-ruiz commented
Hi, I was wondering if is there a way to add --no-header parameter, or maybe a way to define the column's name.
I have duplicated column names in the csv file and I am getting 'field column is ambiguous'
thanks
mithrandie commented
You can use the SET FLAG statement instead of command parameters.
SET @@NO_HEADER TO TRUE; SELECT * FROM `data.csv`;
Or, you can also write it this way if only one file needs the parameter.
SELECT * FROM CSV(',', data, 'UTF8', true);
cf. https://mithrandie.github.io/csvq/reference/select-query.html#from_clause
When column names duplicate, they can be specified by using the table name and column number starting with 1 in the table.
$ cat data.csv
column1,column2,column2,column3
1,A1,B1,101
2,A2,B2,102
$ csvq 'SELECT t.1, t.2, t.3, t.4 FROM `data.csv` t'
+-----+-----+-----+-----+
| t.1 | t.2 | t.3 | t.4 |
+-----+-----+-----+-----+
| 1 | A1 | B1 | 101 |
| 2 | A2 | B2 | 102 |
+-----+-----+-----+-----+