Tag Archives: csv

Load CSV file to MySQL

In many cases it is very convenient to import CSV files directly into the database, so it can be analyzed, referred to and other useful actions. MySQL’s can easily load tables from files, using the LOAD DATA INFILE command, but its default separators do not match the CSV format. Here is the LOAD command, fitted to load CSV files:

LOAD DATA INFILE '/tmp/file.csv'
INTO TABLE the_table
FIELDS
TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'