Importing data from CSV file in mysql

15/02/2009

Use this command to import data from a CSV file into MySQL

LOAD DATA LOCAL INFILE 'data.csv'
INTO TABLE table_name
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
(field1, filed2, field3);

Sample File

"3003","0.039","aster"
"3017","0.03h","affs"
"3018","0.03unit","xfs"

References

  • http://dev.mysql.com/doc/refman/5.0/en/load-data.html

No comments yet.

Write a comment: