Importing partial data into MySQL from CSV

csv, mysql

Solution

It turns out that is the error that tool gives for ANY problems importing CSV data. They have opened a bug for more descriptive error responses.

For me it turned out that it can not work with non-Windows line breaks. So if your file came from Unix/Linux or Mac it will not work. You can just open it in Excel though and re-save it as an MS-DOS CSV and then it works. Other things that can make it throw up are any use of ";".

Also the tool has NO column mapping options so you have to have your import file matched to the table setup perfectly. If you have columns mis-matched or data types mis-matched it will also throw-up.

Problem

I have a CSV that is a partial projection of an origin table. I have the same table structure in my DB. I would like to import only those columns into my DB, given that no additional `NOT NULL` constraints are in place (I explicitly disabled some of them). I don't know how to import them. I have tried the following: from MySQL Workbench, right click on table and then `Edit table data`, then on the screen I tried the "Import records from an external file" button, loaded the CSV file but I got the following error: ``` [Window Title] MySQL Workbench [Main Instruction] Error importing recordset [Content] error calling Python module function SQLIDEUtils.importRecordsetDataFromFile [OK] ``` The column names are the same as in the DB but these are partial (not all columns as DB). The table is currently empty. What can I do to import the data into MySQL?

Original source