q
q copied to clipboard
header in file concatenation
Hi, I have lot of csv file without header, so I thought to add an header file but I get something like this:
$ echo f1,f2 > h.csv
$ echo 1,2 > d.csv
$ q -d, -H "select f1,f2 from h.csv+d.csv"
query error: table temp_table_10001 has no column named c1
Do you have some suggestion to avoid this behaviour without cat of files and pipe to q? Many thanks in advance, Giovanni
I never saw this +
syntax, is that a sqlite feature? Anyway, q -d, "select * from h.csv+d.csv"
seems to work fine, no need to provide column names explicitly. You can also use q -d, -O "select c1 as f1, c2 as f2 from d.csv"
to avoid creating an intermediate header file.
But why don't you want to use cat
? Its exactly made fore usecases like that and you don't even need q
for it.
Thank you bitti for the response. The problem I exposed is simplified: my csv has tens of fields and I would select only a few. Considering that this usage of an header file seems doable by q manual I think that cat and pipe could make less readable a script calling q.