Hello,

I apologize if the question has already been asked before, but I need some 
clarification on the use of .mode and .separator relatively to the .import 
command.

Say I have a structured tab-separated text file "mydata.txt" I want to import 
into a database using the .import FILE TABLE command. If I refer to the 
documentation obtained by typing ".help" in the SQLite shell, it states :
.separator COL ?ROW?   Change the column separator and optionally the row 
separator for both the output mode and .import

But this is in apparent contradiction with the Command Line Shell help :
"Note that it is important to set the "mode" to "csv" before running the 
".import" command. This is necessary to prevent the command-line shell from 
trying to interpret the input file text as some other format. "
https://sqlite.org/cli.html

So, if I use .separator, as hinted by the built-in .help command, I get the 
following
sqlite> .separator tabs
sqlite> .import mydata.txt mytable
I get the following error :
Error: multi-character column separators not allowed for import

So I fall back on my feet by using .mode instead of .separator:
sqlite> .mode tabs
sqlite> .import mydata.txt mytable

But I'd like to understand why .separator does not behave the way I expect it 
to? Is it because there is confusion between the default ".mode" (which is 
comma-separated) onto which I impose a tab through ".separator"?

Thanks for your explanations, and for this great piece of software.

Luc
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to