How to import TSV table with double quote in it without having to escape double quote

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to import TSV table with double quote in it without having to escape double quote

Peng Yu
Hi,

I got the following error. I don't want to escape the quote charaters
in the input. Is there still a way to import quote characters into a
sqlite3 table?

$ cat my.sql3
create table mytab (var text);
.separator "\t"
.import /dev/stdin mytab
$ cat main.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

set -v
> outfile.sqlite3
sqlite3 outfile.sqlite3 '.read my.sql3' <<< '"abc"'
sqlite3 -header -separator $'\t' outfile.sqlite3  "select * from mytab;"

> outfile.sqlite3
sqlite3 outfile.sqlite3 '.read my.sql3' <<< '"abc"|xyz'
sqlite3 -header -separator $'\t' outfile.sqlite3  "select * from mytab;"

$ ./main.sh
> outfile.sqlite3
sqlite3 outfile.sqlite3 '.read my.sql3' <<< '"abc"'
sqlite3 -header -separator $'\t' outfile.sqlite3  "select * from mytab;"
var
abc

> outfile.sqlite3
sqlite3 outfile.sqlite3 '.read my.sql3' <<< '"abc"|xyz'
/dev/stdin:1: unescaped " character
/dev/stdin:1: unterminated "-quoted field
sqlite3 -header -separator $'\t' outfile.sqlite3  "select * from mytab;"
var
abc"|xyz

--
Regards,
Peng
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: How to import TSV table with double quote in it without having to escape double quote

Clemens Ladisch
Peng Yu wrote:
> I don't want to escape the quote charaters in the input. Is there still
> a way to import quote characters into a sqlite3 table?

The CSV import hardcodes " as quote.

You could try the ASCII import instead.


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users