If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > LOAD DATA INFILE from csv and specifying order

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-02-04, 07:42
narcis010 narcis010 is offline
Registered User
 
Join Date: Oct 2003
Posts: 5
LOAD DATA INFILE from csv and specifying order

Hello,

I've been trying to load about 400,000 entries into mysql using LOAD DATA INFILE. I import it from a csv file, however when I try to specify the order of loading fields I always get a syntax error.

This is the code that works:

LOAD DATA CONCURRENT INFILE '/home/virtual/path/var/www/html/FILE' REPLACE
INTO TABLE tbl_name FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n';

However when I type:

LOAD DATA CONCURRENT INFILE '/home/virtual/path/var/www/html/FILE' REPLACE
INTO TABLE tbl_name (col1,col2,col3,col4) FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n';

I always get an error syntax.

Does anyone have a solution? I've searched the web for loading values from a csv file while specifying values load order and I couldn't find anything.

Thanks a lot for your help,

Narcís
Reply With Quote
  #2 (permalink)  
Old 02-02-04, 09:34
vanekl vanekl is offline
Registered User
 
Join Date: Nov 2003
Posts: 91
try moving (col1,col2,col3,col4) to the end of your LOAD DATA statement.
When you get errors you should post them so we can see what the problem is.
Reply With Quote
  #3 (permalink)  
Old 02-08-04, 14:53
narcis010 narcis010 is offline
Registered User
 
Join Date: Oct 2003
Posts: 5
Thanks a lot! it worked! :-)

Narcís
Reply With Quote
  #4 (permalink)  
Old 02-15-04, 10:34
omiossec omiossec is offline
Registered User
 
Join Date: Jan 2003
Location: Paris, France
Posts: 320
To learn more on Load Data you can check this

http://www.lasso-developpeur.net/us/...tab=db&lang=us
__________________
Olivier Miossec
--
http://www.lasso-developpeur.net/
--
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On