1

Using csvkit on macOS 10.14.3

input file:

head -n 3 Nov_git_v2.csv

Model_var,dummy

Age,

Basket_Size_FP_24,

Basket_Size_FP_6,

csvsql --query "select Model_var from Nov_gift_v2"  Nov_gift_v2.csv

produces error:

sqlite3.OperationalError) no such column: Model_var

csvstat -c 1-2 Nov_gift_v2.csv > csvstat_output.txt

displays the column "Model_var" and lists its properties, implying the column exists

csvsql --query "select Model_var from Nov_gift_v2"  Nov_gift_v2.csv

expected:

Age

Basket_Size_FP_24

Basket_Size_FP_6

actual output:

sqlite3.OperationalError) no such column: Model_var

PatrickR
  • 11
  • 2

1 Answers1

0

I have no problem with csvsql 1.0.4. What's your version (csvsql --version)?

Try with

csvsql --query 'select "Model_var" from "Nov_gift_v2"'  Nov_gift_v2.csv
aborruso
  • 4,938
  • 3
  • 23
  • 40
  • I'm on csvsql 1.0.3 – PatrickR Apr 01 '19 at 17:43
  • @PatrickR for me it works. Could you share your file (not simply cut and paste here)? – aborruso Apr 02 '19 at 08:20
  • what's the best way to upload the file ? It's small (43 records, 1 field) – PatrickR Apr 02 '19 at 22:18
  • @PatrickR you could use databin (http://databin.pudo.org/) or gist (https://gist.github.com/). – aborruso Apr 03 '19 at 08:09
  • @PatrickR as you can see in this image I have no error https://i.imgur.com/Y4Asbah.png The command I have used is `curl -sL "http://databin.pudo.org/t/6b64b2.csv" | csvsql --query 'select "Model_var" from stdin' | head` – aborruso Apr 03 '19 at 21:49
  • OK, so the problem is not the data, it's something to do with the setup of csvkit and python 2.7? do you know how i could make csvkit use by python 3.7.2 version? How can i make python 3.7.2 my default version? – PatrickR Apr 04 '19 at 18:03
  • @PatrickR I'm not a mac user. You could do: uninstall csvkit, than install python 3 and pip, and than install csvkit via pip3 (`pip3 csvkit`). Here a tutorial about Python and pip 3 https://evansdianga.com/install-pip-osx/ – aborruso Apr 04 '19 at 21:27