【发布时间】:2011-06-02 17:20:58
【问题描述】:
我在尝试将整个 csv 文件导入 sqlite 数据库时遇到问题。这些是我的终端命令:
sqlite3 DB.sql
create table table1 (id integer primary key, question VARCHAR(500), Aanswer VARCHAR(255), Banswer VARCHAR(255), Canswer VARCHAR(255), Danswer VARCHAR(255));
.mode csv
.import db.csv table1
select * from table1
和输出:
7,"Who's head did Courtney Cox say was on her body in Scream 2?","Heather Graham",Oprah,"*Jennifer Aniston","Demi Moore"
您会注意到它只在几个字段周围加上引号,这似乎是随机的...我不知道这是否是它不会继续导入下一行的原因。
谢谢!
编辑:
这是我的 csv 文件的前几行:
1,What movie follows Cher and Dionne named after great singers of the past that now do infomercials?,10 Things I Hate About You,Cant Hardly Wait,*Clueless,Freeway
2,What 90s movie did critic Janet Maslin describe as : A gale-force movie with the energy to blow audiences right out of the theater?,Avalanche,Aftershocks,Armageddon,*Twister
3,What actress declined Neve Campbell's role in Scream?,*Drew Barrymore,Carla Hatley,Courteney Cox,Rose McGowan
如果我把引号放在自己里面,它会吐出这样的东西:
"""What was the name of Milla Jovovich's character in the Fifth Element?""","""Billy""","""Fog""","""Mugger""","""*Leeloo"""
【问题讨论】:
-
我猜你的 CSV 文件有问题。请发布前 10 行。