导入有条件的CSV文件


1.01,Agricultural Business and Management
1.0101,"Agricultural Business and Management, General"
1.99,"Agriculture, Agriculture Operations, and Related Sciences, Other"
1.9999,"Agriculture, Agriculture Operations, and Related Sciences, Other"
3.01,Natural Resources Conservation and Research

这是我的csv文件格式。有些字段在引号内,有些不在引号内。如果逗号(,)是字段的一部分,则该字段在引号内,否则不在。

i used

load data local infile '/home/zerocool/UnivHub/database/courses.csv'
into table sub_major columns terminated by ',' optionally enclosed by '"' 
escaped by '"' lines terminated by '/n';

显然这里的逻辑不匹配。所以没有行受到影响。如何导入此类csv文件?是否有公式或条件,我可以使用导入csv文件。

create table sub_major(code float(6,4) not null unique, 
                   subject varchar(100),
                   primary key(code));
我使用这个SQL查询来创建我的表

如何像往常一样导入csv到db表,然后尝试通过删除"字符来更新相应的列?

最新更新