Monday, May 8, 2023

 

=============================How do I import CSV file into a MySQL table? ===================================

I have an un-normalized events-diary CSV from a client that I'm trying to load into a MySQL table so that I can refactor into a sane format. I created a table called 'LOS_SCHEME_MAP' that has one field for every column of the CSV file. The CSV contains 4 columns, so this was a hard enough task in itself:

 

Step 1 use this below query for the data load in the table from CSV files .

 

LOAD DATA LOCAL INFILE 

'/home/Op_DBA/LOS_SCHEME_MAP.csv'

INTO TABLE Farukh_3m.LOS_SCHEME_MAP 

FIELDS TERMINATED BY ','

ENCLOSED BY '"'

LINES TERMINATED BY '\n'

IGNORE 1 ROWS

(LDSMLMMEIDN,LDSMLRIDN,LDFICECON,CODE,STATUS,UPDDATE);

 







The LOS_SCHEME_MAP.csv' contains 2.5 CR record lines loaded successfully. The first line contains

 column names. I think it is comma delimited, and text is apparently delimited with double quote.

But still there are lots of completely NULL records, and none of the data that got loaded seems to be in the right place.



Thank you to All ....

Thank you for giving your valuable time to read the above information.

 

 

 

No comments:

Post a Comment