Tag Archives: MySql

Inserting data into table from CSV file in MySql

I wanted to have my data persisted in database for analysis, i had the data in a CSV file and i wanted a quick way to get the data into a table in MySql table. I found this simple but effective solution in StackOverflow

I have a sample CSV file below for reference.

The command below can be used to insert data into Mysql table from command line client.

load data local infile ‘~/tmp/example.csv’ into table rental fields terminated by ‘,’ enclosed by ‘”‘ lines terminated by ‘\n’ (col1,col2,col3,col4,col5,col6,col7,col8,col9

—– CSV File Format —–

“data in quotes”,935,78750,1,1,128,data,708,http://www.bitsbusiness.com/

Leave a comment

Filed under DB