Created
May 23, 2023 10:27
-
-
Save acosonic/4b2e5c70b4c4fe7fe269bd49c9f16c55 to your computer and use it in GitHub Desktop.
Load CSV file in MySQL serverside with fixing date formats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TRUNCATE TABLE `db`.`table`; | |
LOAD DATA LOCAL INFILE '/home/ubuntu/file.csv' IGNORE INTO TABLE `db`.`table` | |
FIELDS TERMINATED BY ',' | |
OPTIONALLY ENCLOSED BY '"' ESCAPED BY '"' LINES TERMINATED BY '\n' IGNORE 1 LINES (`id`, `Name`, | |
`Status`, `AccountNumber`, @v1, | |
@v2, `Business_Street`) | |
SET Formation_Date = STR_TO_DATE(@v1,'%m/%d/%Y'), | |
Production_Date = STR_TO_DATE(@v2,'%m/%d/%Y'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment