Posts

Showing posts from March, 2018

MYSQL -Import Data from Delimited Data

Loading CSV or any delimited data files to MySQL Database. This is a very common task for the developer and the only thing that I think of is LOAD DATA INFILE. The LOAD DATA INFILE statement reads rows from a text file into a table at a very high speed. Here, I will explain how to get the data loaded directly from CSV to MySQL database using commands. For more information, feel free to refer https://dev.mysql.com/doc/refman/5.7/en/load-data.html a) Copy the complete CSV file data including header LOAD DATA LOCAL INFILE 'path/of/csv/file' INTO TABLE <TABLE NAME> FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' Path: '/home/user/file_name.csv' or in windows 'C:/path/file_name.csv' FIELDS TERMINATED BY ',': Divides the line data into Fields Example: A table with three columns say A,B,C and CSV file is as follows a,b,c aa,bb,cc aaa,bbb,ccc By terminating by delimited ',' fields table would look like ...