Skip to content
Tags

mysql load data infile y ficheros csv

by david on enero 14th, 2010

Si necesitamos cargar un fichero csv en mysql, en lugar de hacer un script en php que recorra el fichero e inserte los datos en nuestra tabla. Mysql nos facilita el comando load data infile.

1
2
3
4
5
LOAD DATA INFILE '/tmp/mi-fichero.csv'
INTO TABLE my_table
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n'
(col1,col2,...,coln)

Más información del comando en la web oficial de mysql:

From → Mysql, Tips

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS