问题
直接用load data infile将csv格式导入Mysql中数据为空;
代码如下:
load data infile 'E:\\python\\sample_On_Time_On_Time_Performance_2015.csv'
into table on_time_performance;
解决方法
load data infile 'E:\\python\\sample_On_Time_On_Time_Performance_2015.csv'
into table on_time_performance character set utf8
fields terminated by ','
ignore 1 lines;
猜测问题在于csv文件需要一个逗号分隔符的语句,即fields terminated by ‘,’;
因为还有表中第一列为表头,所以只保留数据的话最好加一句ignore 1 lines;