On Fri, Aug 12, 2011 at 14:59, matthew (matthew.jsoft) white
<matthew.js...@btinternet.com> wrote:
>
> This may seem obvious for seasoned users, but sqlite3 always turns every 
> blank input token into an empty string.
>
> For example, say you are dot.importing a colon separated file such as :-
>
> create table foo ( col1 integer, col2 varchar(100) );
>
> .separator ":"
>
> 1001:'a_string'      -- dynamic string into column 2
> 1002:''                 -- string of length two " into column 2
> 1003:null             -- explicit null into column 2
> 1004::                 -- empty type-less value into column 2
>
> Would there be any way of reading an external data file into a table with 
> blank fields being replaced by nulls?

Assuming you do not have things like :: inside of strings, you could
pre-process the text file, replacing :: with :null:, ^: with ^null:,
and :$ with :null$, ^ and $ being the start of line and end of line
markers respectively.  If :: can exist inside of strings, the
substitution gets trickier to do right.
[ .. snip .. snip .. ]
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to