textql icon indicating copy to clipboard operation
textql copied to clipboard

Headers with column names containing spaces not supported

Open ghost opened this issue 7 years ago • 5 comments

input.csv:

Column 1,Column 2
A,B
C,D

Query:

textql -header -sql 'select [Column 1]' input.csv

Expected result:

A
C

Actual result:

2017/05/23 15:21:00 no such column: Column 1

Quoting the column names does not help.

ghost avatar May 23 '17 19:05 ghost

The same problem seems to exist for column names containing dots, like Column.1

arendtio avatar Apr 20 '18 09:04 arendtio

I got this working if I quote the fields AND leave the FROM clause in the SQL statement.

EG: textql -header -sql 'select [Column 1] from [input]' input.csv

awildeep avatar Apr 25 '18 15:04 awildeep

I can confirm the workaround by @awildeep works for columns with dots too.

arendtio avatar Apr 25 '18 20:04 arendtio

The workaround also works when working on stdin by selecting from the table named stdin like this:

$ echo "Column 1,Column 2
A,B
C,D" | textql -header -sql 'select [Column 2] from stdin'
B
D

Backticks can also be used instead of square brackets.

gabrielf avatar Mar 11 '20 13:03 gabrielf

I think this issue could be closed with some documentation surrounding these work-arounds.

awildeep avatar Mar 11 '20 14:03 awildeep