gpt4 book ai didi

sqlite - 无法从csv文件导入多行到sqlite数据库

转载 作者:行者123 更新时间:2023-12-03 15:30:09 26 4
gpt4 key购买 nike

我在尝试将整个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"""

最佳答案

sqlite的.import命令仅能识别LF(0xA)行尾代码,而不能识别CR(0xD)。在十六进制编辑器中检查您的输入文件。

关于sqlite - 无法从csv文件导入多行到sqlite数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6217876/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com