Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems importing text files

Status
Not open for further replies.

roardood

Technical User
Apr 11, 2002
11
ZA
Hi all

This is probably a newbie question, but seeing as that's what I am, please bear with me. I have a file that I need to import (comma-seperated variables) into a MySQL table. There are three fields, two of which are arbitrary, and one in which I am interested. The field I am interested in contains a string of data which is a concatenated call record containing information about call time, phone extension used, number called, call duration etc. Each record represents a phone call, and as a whole is therefore unique.

However, when I try to import using "LOAD DATA" MySql appears to be dropping about half the records - I run the import from a batch file, but I am not seeing any error messages - and the records that are being dropped are unique, with no apparent common factor.

Can anybody suggest a solution to this ? Or even give me some idea of where to start looking?

Many Thanks

roardood
 
provided the fields are like:
"field1","field2","field3"
"field1","field2","field3"
"field1","field2","field3"
"field1","field2","field3"
and none of the contents contain , or " the following should work
LOAD DATA local infile 'path/to/file.csv' fields enclosed by '"' terminated by ',' lines terminated by '\n' into TABLE table;
***************************************
Party on, dudes!
[cannon]
 
Thanks KarveR

I was doing that, but it didn't help. My text field was exactly like your example, but I found that if I didn't use the enclosed by parameter, the problem went away (even though the fields are enclosed by ").I will post the issue under a new thread, but I just need to have to the time to write it up.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top