3

I have seen other posts and tried the answers but it still will not create the table for me.

I simply want to import a .tab file into a new sqlite3 table on the fly.

I have tried .mode csv with a .separator '\t' and .mode tabs

I have the following command and error.

sqlite> .mode tabs

sqlite> .import /storage/mgymrek/gtex-estrs/revision/mastertables/Adipose-Subcutaneous_master.csv Temp1

Error: no such table: Temp1

I have also tried

sqlite3 -separator '\t' estr.db ".import Adipose-Subcutaneous_master.csv Temp1"

Error: no such table: Temp1

Please help!

Community
  • 1
  • 1
user2945234
  • 418
  • 6
  • 12

2 Answers2

0

To import a CSV file in SQLit3, set the mode to csv. If it's a tab-seperate-file, you could try importing the file as shown in: How to import a tsv file with SQLite3

sqlite> .mode csv

sqlite> .import /storage/mgymrek/gtex-estrs/revision/mastertables/Adipose-Subcutaneous_master.csv Temp1

Community
  • 1
  • 1
zmike
  • 1,090
  • 10
  • 24
  • 1
    Thank you for the answer. That is where I started .mode csv and .separator '\t' . No luck – user2945234 Jul 10 '19 at 18:30
  • If you want to keep the file as a TSV (tab separated values) file, then it seems you'll need to create the table before importing it. Alternatively, you can save the file as a CSV (replacing the tabs with commas). – zmike Jul 10 '19 at 18:48
0

As per this answer, if you have an older version of SQLite this will happen. I'm not sure in which version the automatic creation of a table was implemented, but from that post if you have SQLite 3.8.9 or newer it should automatically create the table, possibly a few versions before would also do that. If you have 3.7.17 or older it won't create the table, this is the version I have and it doesn't work (I arrived here investigating why). I don't know the versions in-between, but if you're there and it's not working for you I suggest you upgrade.

msb
  • 3,899
  • 3
  • 31
  • 38