MySQL Forums
Forum List  »  MySQL Query Browser

Import from CSV file resulting in all fields being null
Posted by: William Hutchinson
Date: December 15, 2010 09:37AM

Using the CSV using LOAD DATA functionality to load my CSV datafile into a MySQL table, the primary key field gets populated as it should, however, all the other fields result with NULL values.

For example the table is called members with the following structure:
FIELD_____TYPE_________COLLATION______NULL______DEFAULT
MemberID__int(11)_______________________No________None
FirstName__varchar(20)___utf8_general_ci____Yes_______NULL
LastName__varchar(20)___utf8_general_ci____Yes_______NULL
eMail_____varchar(50)____utf8_general_ci____Yes_______NULL
Access____varchar(15)_____________________No_______Guest
ListMe____tinyint(1)______________________Yes_______NULL

The csv file being import is something like:
11,"John","Doe","JohnDoe@domain.com","Guest",0
12,"Jane","Doe","JaneDoe@domain.com","Guest",-1

The resulting data imported looks something like:
11,NULL,NULL,NULL,,NULL
12,NULL,NULL,NULL,,NULL

The automated SQL looks something like:
LOAD DATA LOCAL INFILE ''C:\\Users\\MyComputer\\Documents\\members.csv'' INTO TABLE `members` FIELDS TERMINATED BY ';' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\r\n'

No matter what I try (including the replace option), I continue to get the above resulting null data imported and not the actual data. Does anyone know how to get the data into my database?

Options: ReplyQuote


Subject
Written By
Posted
Import from CSV file resulting in all fields being null
December 15, 2010 09:37AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.