Thanks Kees.

2013/2/21 Kees Nuyt <k.n...@zonnet.nl>

> On Thu, 21 Feb 2013 18:00:58 +0100, Gert Van Assche
> <ger...@datamundi.be> wrote:
>
> >If I remove the double quotes, the problem is solved indeed.
> >I'm working on windows. Do you know if there is an alternative to the SED
> >command or tool?
>
> For just removing double quotes, I would recommend the tr (translate)
> program. Something like:
>
>         echo "CREATE TABLE Source (Segments TEXT);" | sqlite3 dbfile
>         tr -d '"' <test.txt >import.txt
>         sqlite3 dbfile .import import.txt Source
>
> The sed (stream editor) is fine here too, as demonstrated before.
> For a general stream editor I would recommend gawk, which is much easier
> and more powerful than tr or sed when the transformations get more
> complicated.
>
> With gawk it is easy to create INSERT statements (from the top of my
> head, untested).
>
> gawk -f xform.awk test.txt | sqlite3 dbfile
>
> xform.awk contains:
> ###########################
> BEGIN{
>         FS     = ""
>         insfmt = "INSERT INTO Source (Segments) VALUES ('%s');\n"
>         print "CREATE TABLE Source (Segments TEXT);"
>         print "BEGIN;"
> }
> # the following action is executed for every input line
> {
>         gsub(/"/,"")    # remove double quotes
>         gsub(/'/,"''")  # escape every single quote with another single
> quote
>         printf insfmt,$0
> }
> END{
>         print "COMMIT;"
> }
> ############################ EOF
>
> tr, sed and gawk have implementations on Windows, for example in
>
> http://unxutils.sourceforge.net/
>
> Note: you need both UnxUtils.zip and UnxUpdates.zip
>
> >Or is there a way I can force sqlite3 to ignore these double quotes?
> >
> >thanks
> >
> >gert
>
> --
> Groet, Cordialement, Pozdrawiam, Regards,
>
> Kees Nuyt
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to