所以我试图用 sqlite3 将一个 csv 文件导入到一个表中,但出现错误,这是我用来导入文件的表架构和命令以及它按顺序出现的错误:
CREATE TABLE Artist(
Art_ID int not null primary key,
Art_Name varchar(30),
Followers int,
Art_Genres varchar(200),
NumAlbums int,
YearFirstAlbum int,
Gender char(1),
Group_Solo varchar(5)
);
sqlite>
sqlite> .import '| tail -n +2 /Users/adrianogiunta/Desktop/artistDF.csv' Artist
<pipe>:1: expected 8 columns but found 1 - filling the rest with NULL
<pipe>:2: expected 8 columns but found 1 - filling the rest with NULL
<pipe>:3: expected 8 columns but found 1 - filling the rest with NULL
<pipe>:4: expected 8 columns but found 1 - filling the rest with NULL
<pipe>:5: expected 8 columns but found 1 - filling the rest with NULL
<pipe>:6: expected 8 columns but found 1 - filling the rest with NULL
对于其余的 1035 行。
这些是 csv 文件的第一行:
X,Artist,Followers,Genres,NumAlbums,YearFirstAlbum,Gender,Group.Solo
0,Ed Sheeran,52698756,"pop,uk pop",8,2011,M,Solo
1,Justin Bieber,30711450,"canadian pop,dance pop,pop,post-teen pop",10,2009,M,Solo
2,Jonas Brothers,3069527,"boy band,dance pop,pop,post-teen pop",10,2006,M,Group
3,Drake,41420478,"canadian hip hop,canadian pop,hip hop,pop rap,rap,toronto rap",11,2010,M,Solo
4,Chris Brown,9676862,"dance pop,pop,pop rap,r&b,rap",6,2005,M,Solo
5,Taylor Swift,23709128,"dance pop,pop,post-teen pop",10,2006,F,Solo
这是我的表格之后显示的内容:
sqlite> SELECT * FROM Artist LIMIT 5;
0,Ed Sheeran,52698756,"pop,uk pop",8,2011,M,Solo|||||||
1,Justin Bieber,30711450,"canadian pop,dance pop,pop,post-teen pop",10,2009,M,Solo|||||||
2,Jonas Brothers,3069527,"boy band,dance pop,pop,post-teen pop",10,2006,M,Group|||||||
3,Drake,41420478,"canadian hip hop,canadian pop,hip hop,pop rap,rap,toronto rap",11,2010,M,Solo|||||||
4,Chris Brown,9676862,"dance pop,pop,pop rap,r&b,rap",6,2005,M,Solo|||||||
sqlite>
预先感谢您的帮助!
答案 0 :(得分:3)
Bigram Frequency : {'ab': 5, 'ba': 4, 'bb': 1}
命令默认查找 SQLite 的转储格式。在尝试导入 CSV 之前,您需要输入 .import
。正如文档所说。