Reputation: 4028
I am trying to load csv file into my table. I've run the following code which throws error
LOAD DATA LOCAL INFILE 'info.csv' INTO TABLE tbl_countryip (ipstart, ipend, countrycode) FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' ;
The error is
bash: syntax error near unexpected token `('
I even tried after removing the space between tablename and column names but still the same error Thanks in advance
Upvotes: 1
Views: 459
Reputation: 1085
Try this syntax-
LOAD DATA LOCAL INFILE 'info.csv'
INTO TABLE tbl_countryip
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(col1, col2, col3, col4, col5...);
Hope the below reference link help you
Upvotes: 1
Reputation: 7065
You need to do following changes:
\r
from LINES TERMINATED BYUpdated Query
LOAD DATA LOCAL INFILE 'info.csv'
INTO TABLE tbl_countryip
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
If first row in your csv file is a column name, use IGNORE 1 LINES
after LINES TERMINATED
.
Upvotes: 0