开发者

import on csv to sqlite3 crashes

开发者 https://www.devze.com 2023-01-07 10:31 出处:网络
I have a csv file that is comma delimited. I have no pr开发者_运维技巧oblem with the importing aspect of it except for when the import reaches a line like this:

I have a csv file that is comma delimited. I have no pr开发者_运维技巧oblem with the importing aspect of it except for when the import reaches a line like this:

1,2,3, Canada's,5, 6,7

The import crashes when it reaches the single quote. Does anyone know of a program I could use to import my csv file in to sqlite database without having to get rid of all my single quotes?


Try this on the command line (i.e. in Terminal):

cat filename.csv | sed "s/'/\\\\'/g" > new_filename.csv

That will create a new file with all the single quotes escaped with a backslash, which should allow you to import it. Of course, it depends on whether your importer recognizes backslashes, but it's worth a try :-)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号