'MySQL database migration from CSV file
I want to migrate a CSV file into my database. I'm using a terminal window to execute the queries. My issue is the CSV file I'm migrating has empty rows which will produce an error while migrating (duplicate primary ids) to my database.
I was wondering how to import only rows that do not have null values for the first column?
Solution 1:[1]
Workbench should have an option to ignore blank lines on import. Otherwise, you can always write a quick script to remove blank lines from your csv file and then import.
Solution 2:[2]
Ultimately, if your input is giving you wrong results, you must change the input in order to change the results.
For example, you could open the CSV in excel, sort by the first column, delete all the lines that are now grouped together with null in the first column, save as new csv file, import to mysql.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | SS781 |
| Solution 2 | Billy Moon |
