Loading data with INFILE

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Loading data with INFILE

Postby georgec » 18. February 2009 04:30

I would like to import data from a csv and at the same time alter a date field from YYYY-MM-DD to MM-DD-YYYY. If I use the following command, where do I place my source .csv file?

LOAD DATA [LOCAL] INFILE 'file_name'
INTO TABLE tbl_name
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
(field1,field2,field3,varcharDate,...)
SET `date` = STR_TO_DATE( varcharDate, '%m-%d-%Y' ) ;
georgec
 
Posts: 11
Joined: 29. January 2009 22:38
Operating System: Windows 7 Pro 64b

Re: Loading data with INFILE

Postby Wiedmann » 18. February 2009 08:23

If I use the following command

You get an error message... (brackets "[" / "]" surrounds an optional part, which must be used without the brackets).

where do I place my source .csv file?

This depends on, if you use "local" or not:
http://dev.mysql.com/doc/refman/5.1/en/load-data.html
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 49 guests