2016-11-24 123 views
1

試圖使用LOAD DATA LOCAL INFILE從CSV文件導入數據到MySQL表:加載數據從CSV文件LOCAL INFILE其中字段不括

LOAD DATA LOCAL INFILE 'wentronic.csv' INTO TABLE wentronic1 fields OPTIONALLY ENCLOSED BY \"\" ignore 1 lines 

從CSV A線:

29995;LED Driver 10-24 V (DC)/12-20 W - dimmable, 3 output voltages, 3 output currents;96869;LED Driver 10-24 V (DC)/12-20 W<br>dimmable, 3 output voltages, 3 output currents;4040849299957;01;23,66;00;0;00;0;00;0;00;0;350;1;Goobay;36;85043180900;;Goobay LED Driver 10-24 V (DC)/12-20 W, Plastic bag - dimmable, 3 output voltages, 3 output currents<br>DC current source for LEDs with electronic ballast unit<br>output voltage adjustable: 10 V/12 W, 12 V/14 W, 24 V/20 W<br>Output current adjustable: 350mA, 700mA, 1000mA<br>secured in four ways: short circuit, overheat, overload, idling<br>approved for installation in furniture<br>safe electronic separation as per protection class II;CN;0;;4,5;2;43,99;;Length;110;mm;Number of outputs;2;pieces;Output, max. amperage;1000;mA;Dimmability;dimmable;;max. performance;20;W;Width;52;mm;Height;24;mm;Output, voltage;24;V (DC);Input, Voltage Range;220 - 240 (AC);V;Appliance Class;II;;;;;;;;;;;;;;;;;1;4040849299957;0;0;0;0;0;0;0;0 

問題是,沒有任何字段有引號,只有表格中的整數字段被導入。正如你所看到的,我試圖「欺騙」MySQL,說這些字段可以被封閉......沒有:-)

任何幫助嗎? :-)

回答

1

這個怎麼樣?

LOAD DATA LOCAL INFILE '/path/to/wentronic.csv' INTO TABLE wentronic1 FIELDS TERMINATED BY ';' IGNORE 1 LINES; 

它看起來像你的字段由分號結束,如果這是真的,你不介意的字段由任何封裝。

+0

完美,對,你是,謝謝。事實上,我首先嚐試了,但我想我得到了錯誤的語法 - 認爲我把字段放在前面:-) –