I'm trying to import a csv file with a PHP procedure. However, some of the
lines in the csv file have missing values.
When this command is given to mysql:
insert tablex values
('2006-01-06','IHS',127,, ,,,,,3.45,-0.33,12.82,,,,, ,40.64,17.41,79 .22,,,,,,3,3,3. 00,15,0.51,0.40 ,0.38,3904,,,49 8.24,,,,,,71.03 ,,,,,,7.098505e-03,,,,,,2.87,,, ,,,0.34,,,,,,1. 01,1.07,,
)
Here is the error message:
You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right syntax
to use near
',,,,,3.45,-0.33,12.82,,,,, ,40.64,17.41,79 .22,,,,,,3,3,3. 00,15,0.51,0.40 ,0.38,390'
at line 1
The table consists of 69 columns. col 1 is a date, col 2 is char, col
is integer and the remaining 66 are float.
Here is a snip of the table defs:
+-----------+----------+------+-----+------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+----------+------+-----+------------+-------+
| Date | date | | PRI | 0000-00-00 | |
| Symbol | char(10) | | PRI | - | |
| RIL | int(11) | YES | | NULL | |
| Mn26wRet | float | YES | | NULL | |
| SD26wRet | float | YES | | NULL | |
|
Am I going to have to recode this by exploding the csv file line by line
and creating a series of update statements?
John
lines in the csv file have missing values.
When this command is given to mysql:
insert tablex values
('2006-01-06','IHS',127,, ,,,,,3.45,-0.33,12.82,,,,, ,40.64,17.41,79 .22,,,,,,3,3,3. 00,15,0.51,0.40 ,0.38,3904,,,49 8.24,,,,,,71.03 ,,,,,,7.098505e-03,,,,,,2.87,,, ,,,0.34,,,,,,1. 01,1.07,,
)
Here is the error message:
You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right syntax
to use near
',,,,,3.45,-0.33,12.82,,,,, ,40.64,17.41,79 .22,,,,,,3,3,3. 00,15,0.51,0.40 ,0.38,390'
at line 1
The table consists of 69 columns. col 1 is a date, col 2 is char, col
is integer and the remaining 66 are float.
Here is a snip of the table defs:
+-----------+----------+------+-----+------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+----------+------+-----+------------+-------+
| Date | date | | PRI | 0000-00-00 | |
| Symbol | char(10) | | PRI | - | |
| RIL | int(11) | YES | | NULL | |
| Mn26wRet | float | YES | | NULL | |
| SD26wRet | float | YES | | NULL | |
|
Am I going to have to recode this by exploding the csv file line by line
and creating a series of update statements?
John
Comment