這裏是原始CSV(從Quandl)的一個片段:負載CSV到MySQL工作臺表
Date,Open,High,Low,Close,Volume_BTC,Volume_Dollar,Weighted_Price
13/02/2014,650.04,660,645.07,645.24,4027.229102,2628148.177,652.5946528
12/02/2014,677,685.19,631.58,651.99,15511.78726,10224606.46,659.1507667
這裏是SQL代碼,我想,這我已經嘗試了許多排列:
load data local infile '/../BITSTAMPUSD.csv'
into table test.BTC
CHARACTER SET utf8
FIELDS TERMINATED BY ','
enclosed by ""
LINES TERMINATED BY '\n'
IGNORE 1 LINES;
這是我一直得到的錯誤:
1 row(s) affected, 8 warning(s): 1265 Data truncated for column 'Date' at row 1 1265 Data truncated for column 'Open' at row 1 1265 Data truncated for column 'High' at row 1 1265 Data truncated for column 'Low' at row 1 1265 Data truncated for column 'Close' at row 1 1265 Data truncated for column 'Volume_BTC' at row 1 1265 Data truncated for column 'Volume_Dollar' at row 1 1265 Data truncated for column 'Weighted_Price' at row 1 Records: 1 Deleted: 0 Skipped: 0 Warnings: 8
這裏是我用來生成表格是代碼搭配:
CREATE TABLE BTC(
Date DATE,
Open FLOAT,
High FLOAT,
Low FLOAT,
Close FLOAT,
Volume_BTC FLOAT,
Volume_Dollar FLOAT,
Weighted_Price FLOAT
)
我一直在打我的頭靠在這個問題有一段時間了,所以任何的幫助深表感謝。
更新:我已經嘗試了一些建議,仍然沒有解決。我懷疑它與線路終止有關。我使用Mac是有所作爲的。 '/ n'是否正確?
在MySQL 5.3.34上,我可以實際導入你指定的文件(除了錯誤的日期格式,(請參閱[這個問題])(http://stackoverflow.com/questions/10102167/load-data -infile-easily-convert-yyyymmdd-to-yyyy-mm-dd)來解決這個問題)。 –
如果使用工作臺,另一種方法是通過數據導入/導出嚮導運行它。 – chrisboustead