How to import multi-line feeds?
I want to
.import a file where some fields contain line feeds (LF) encoded as some unique string pattern.
I know with SQL one can use the
|| char(10) || trick.
But, how to do the same with the
.import shell command?
Is there some way to tell the SQLite3 shell to interpret a certain char sequence as LF during
.import? For example, interpret
\n as LF?
You can use the SQL
REPLACE function, perhaps (although, depending on what exactly you will want to do, it might not be good enough, since it does not support e.g. replacing two backslashes with a single slash and replacing other escapes at the same time without interference).
If you want to customize the import handling, one thing that I have done is to create a view and attach triggers to it, and then to import into that view instead of directly into the table that you want to import data into. (If needed, you can also create another table to store temporary state during importing if the format you are importing requires saving the state between records of the input file.)
I'm not aware of a method to set an arbitrary hex value for a field or record separator (though I could swear that strings were acceptable as separators in some ancient version of the CLI -- maybe I just dream in sqlite.)
I don't know if
would be of any use to you.
It's described as: "Columns/rows delimited by 0x1F and 0x1E"
A hack might be to use the CLI's file functions to read the import file into a single blob field in a temporary 1-row table, perform a REPLACE or two, then write it back out as your new import file.
Someone here may have a better answer.