I am working on a project that requires importing csv data into a mysql table using Workbench. I tried running the command below. I am not getting any errors, however no records are being imported in to the table. Note, I tried changing the line terminated by to \n
, also tried \r
, which resulted in the same outcome.
I appreciate any suggestions on how to resolve.
This is the query I tried:
LOAD DATA LOCAL INFILE 'data-to-import.csv' INTO TABLE db.t1
COLUMNS TERMINATED BY ','
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(id,age,spns,pns,spns2,sns,ps,ss,gid,term,band)
data-to-import.csv
,18,0.455,0.62,0.774,1.083,2.408,3.702,1,10,1
,19,0.455,0.62,0.774,1.083,2.408,3.702,1,10,1
,20,0.455,0.62,0.774,1.083,2.408,3.702,1,10,1
,21,0.455,0.62,0.774,1.083,2.408,3.702,1,10,1
,22,0.455,0.62,0.774,1.083,2.408,3.702,1,10,1
,23,0.455,0.62,0.774,1.083,2.408,3.702,1,10,1
,24,0.455,0.62,0.774,1.083,2.408,3.702,1,10,1
,25,0.455,0.62,0.774,1.083,2.408,3.702,1,10,1
,26,0.455,0.62,0.774,1.083,2.408,3.702,1,10,1
,27,0.455,0.62,0.774,1.083,2.408,3.702,1,10,1
,28,0.455,0.62,0.774,1.088,2.416,3.702,1,10,1
,29,0.455,0.62,0.792,1.121,2.489,3.702,1,10,1
db.t1 definition
CREATE TABLE `t1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`age` int(11) NOT NULL,
`spns` decimal(4,4) NOT NULL,
`pns` decimal(4,4) NOT NULL,
`spns2` decimal(4,4) NOT NULL,
`sns` decimal(4,4) NOT NULL,
`ps` decimal(4,4) NOT NULL,
`ss` decimal(4,4) NOT NULL,
`gid` int(11) NOT NULL,
`term` int(11) DEFAULT NULL,
`band` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;