This pull request sets the field names of the SQLite database as the values of the corresponding header column name, with the modification that numerical header column names get prepended with 'c'.
Tests
White House budget proposal FY2016
The White House just released the first ever federal budget proposal on github as a few CSV files, however, the receipts.csv file has 72 field names, and it very quickly becomes unwieldy to query it using textql referring to c52 and c68 and keeping track of all those names.
If you check out the budget repository and look at the receipts.csv file, run this command:
As you can see, the field names are named after the column names, instead of c1,c2,....,cN, which are much harder to deal with.
Oneliner
$ printf 'foo,bar\n2,3\n5,8\n' | textql -header=false -sql='select foo from tbl where bar=8'
5
Possible alternatives to this approach
If the default behavior of making the field names c1,c2,...,cN is worth preserving, I can make it another flag, such as -fieldsConsecutive=true or something like that.
This pull request sets the field names of the SQLite database as the values of the corresponding header column name, with the modification that numerical header column names get prepended with 'c'.
Tests
White House budget proposal FY2016
The White House just released the first ever federal budget proposal on github as a few CSV files, however, the receipts.csv file has 72 field names, and it very quickly becomes unwieldy to query it using textql referring to c52 and c68 and keeping track of all those names.
If you check out the budget repository and look at the receipts.csv file, run this command:
Then run
As you can see, the field names are named after the column names, instead of c1,c2,....,cN, which are much harder to deal with.
Oneliner
Possible alternatives to this approach
If the default behavior of making the field names c1,c2,...,cN is worth preserving, I can make it another flag, such as
-fieldsConsecutive=true
or something like that.