sqlite separator
(1) By anonymous on 2022-10-20 08:41:49 [link] [source]
I wang import data from a txt file to the sqlite,the txt file separator by x'01', who can tell me how to set separator in the sqlite? Thank you very much!
(2) By Aask (AAsk1902) on 2022-10-20 13:24:42 in reply to 1 [link] [source]
If you are using the CLI's .import command, I believe your column separator MUST be a non-null character (x'01' is the null character).
Consider replacing the null separator by another character: can you use the conventional comma as the column separator?
(3) By Donal Fellows (dkfellows) on 2022-10-20 13:35:04 in reply to 2 [link] [source]
x'01' is the null character
No, it is not. x'00'
would be NUL, and x'01'
would be SOH.
(4.2) By Aask (AAsk1902) on 2022-10-20 13:58:27 edited from 4.1 in reply to 3 [link] [source]
From the CLI, this worked for me:
SQLite version 3.39.2 2022-07-21 15:24:47
Enter ".help" for usage hints.
sqlite> .separator "\01"
sqlite> .import e:/temp/ajay.txt t10
sqlite> select * from t10;
name factor
-------- ------
ajay 100.78
askoolum 200.78
sqlite>
Don't forget to substitute your file name and table name, as appropriate.
In my text editor, e:/temp/ajay.txt looks like:
namefactor
ajay100.78
askoolum200.78
(6) By anonymous on 2022-10-21 00:24:06 in reply to 4.2 [source]
your anwser is correct,thank you.
(5) By Kees Nuyt (knu) on 2022-10-20 13:54:58 in reply to 1 [link] [source]
Example:
knu@f7p3:~ $ echo abc^Adef>tmp/tmp.in
knu@f7p3:~ $ echo ghi^Ajkl>>tmp/tmp.in
knu@f7p3:~ $ rm -f tmp/test.sqlite ; sqlite3 tmp/test.sqlite ".separator ^A" ".import 'tmp/tmp.in' newtab" ".tables" ".mode column" "SELECT * FROM newtab"
newtab
abc def
--- ---
ghi jkl
Note: x01 is the same as Ctrl+A .
In a Linux or Unix system, you can enter that on the command line or in vi by typing Ctrl+V followed by Ctrl+A
--
Regards,
Kees NUyt