Brian Langhoff
Brian Langhoff

Reputation: 151

Load data local infile from CSV file where fields are not ENCLOSED

trying to import data from a csv file into a mysql table using load data local infile:

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

A line from the csv:

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

Problem is that none of the fields have quotes, and only the fields that are integers in the table are imported. As you can see, I tried to "trick" mysql by saying that fields were optionally enclosed by ... nothing :-)

Any help? :-)

Upvotes: 1

Views: 1006

Answers (1)

Benny Hill
Benny Hill

Reputation: 6240

How about this?

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

It looks like your fields are terminated by a semi-colon, if that's true you don't care if the fields are encapsulated by anything.

Upvotes: 1

Related Questions