将大型CSV文件导入MySQL工作台

时间:2014-12-28 06:00:13

标签: mysql csv mysql-workbench

我正在研究一个数据集的数据分析。 140,000条记录。我的数据集是 CSV文件。 我正在尝试将数据导入MySQL工作台,但它只处理(添加)第一条记录,并发出1265行被截断的警告。 像这样的东西

" 0行受影响,1个警告:1265数据截断列'位置'在第1行记录:1删除:0跳过:1警告:1 "

我的实际查询是:

LOAD DATA LOCAL INFILE 'D:/PMK/SFPD_Incidents.csv' INTO TABLE incidents.incidents 
FIELDS TERMINATED BY ',' 
ENCLOSED BY '"' 
LINES TERMINATED BY '\r\n'
(IncidntNum, Category, Description, DayOfWeek, Date, Time, PdDistrict, Resolution, Address, X, Y, Location);

现在,当我为具有较少记录的小数据集运行相同的查询时,除了截断警告之外,它完全正常。

csv内容如下所示:

141043385,SUSPICIOUS OCC,SUSPICIOUS OCCURRENCE,Thursday,12/11/2014,21:09,SOUTHERN,NONE,800 Block of BRYANT ST,-122.403404791479,37.775420706711,"(37.775420706711, -122.403404791479)"
141043523,NON-CRIMINAL,"AIDED CASE, MENTAL DISTURBED",Thursday,12/11/2014,19:28,SOUTHERN,NONE,800 Block of MARKET ST,-122.407633520742,37.7841893501425,"(37.7841893501425, -122.407633520742)"
141042804,LARCENY/THEFT,GRAND THEFT PICKPOCKET,Thursday,12/11/2014,15:45,TENDERLOIN,NONE,100 Block of OFARRELL ST,-122.407244087032,37.7865647607685,"(37.7865647607685, -122.407244087032)"
141042622,SUSPICIOUS OCC,SUSPICIOUS OCCURRENCE,Thursday,12/11/2014,15:00,TARAVAL,NONE,0 Block of FUENTE AV,-122.477993371794,37.7193838455847,"(37.7193838455847, -122.477993371794)"
141042622,OTHER OFFENSES,FALSE PERSONATION,Thursday,12/11/2014,15:00,TARAVAL,NONE,0 Block of FUENTE AV,-122.477993371794,37.7193838455847,"(37.7193838455847, -122.477993371794)"

非常感谢任何帮助或修复。

1 个答案:

答案 0 :(得分:0)

您应该尝试验证/验证它。

我也遇到过大型CSV文件的问题,但大多数情况下这些值都存在问题。

因此可能存在破坏导入的价值。