q
q copied to clipboard
Question - can I join multiple CSV tables
I want to compare values from 2 seperate csv files , for instance a trivial query like this , but I get an error that the column doesn't exist
q "select * from /tmp/1.csv as a inner join /tmp/2.csv as b where a.sku=b.sku" -d ","
query error: no such column: a.sku
If I change to a different column the result seems to be returned
q "select * from /tmp/1.csv as a inner join /tmp/2.csv as b where a.c1=b.c1" -d ","
sku,c1,c2,sku,c1,c2,c3
a,b,c,a,b,c,d
c,d,e,c,e,e,f
d,e,f,d,e,f,g
If i'm not missing something, then you need to add -H to the command line so the header row will be used to name the columns. If i'm missing something, please send the first few rows of the two files as an example, or some small dummy data, so i can understand the issue better.
You can also run the query using -A - This will analyze the data and show you the resulting "table" structure that q has determined, along with column names and types.