Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In MySQL Workbench, using "Table Data Import Wizard" to import CSV creates empty table

I am attempting to import a csv file into a MySQL table using the Table Data Import Wizard. The sample section at the bottom of the Configure Import Settings screen looks fine and when I run the import, it says all of my entries were loaded successfully. However, when I go to view the contents of the table, only the columns are there and none of my actual data loaded. Does anyone know why this might be happening and how to correct it?

EDIT:

These are a few lines from my CSV file:

STATION,STATION_NAME,ELEVATION,LATITUDE,LONGITUDE,DATE,MLY-TAVG-NORMAL,MLY-TMAX-NORMAL,MLY-TMIN-NORMAL,Average Temp,Max Temp,Min Temp GHCND:USW00094085,PIERRE 24 S SD US,647.4,44.0194,-100.353,201001,218,322,113,21.8,32.2,11.3 GHCND:USW00094085,PIERRE 24 S SD US,647.4,44.0194,-100.353,201002,246,354,137,24.6,35.4,13.7 GHCND:USW00094085,PIERRE 24 S SD US,647.4,44.0194,-100.353,201003,339,451,226,33.9,45.1,22.6 GHCND:USW00094085,PIERRE 24 S SD US,647.4,44.0194,-100.353,201004,463,588,337,46.3,58.8,33.7 GHCND:USW00094085,PIERRE 24 S SD US,647.4,44.0194,-100.353,201005,573,696,450,57.3,69.6,45

Here are some images of the import process: Image1

Image2

Image3

Image4

Image5

Image6

And here is what I see when I attempt to view the newly created table: Image7

Second Edit:

Here is an image of my settings:

Settings

And here is an image of my CSV file showing line endings:

enter image description here

like image 462
Erik Hanson Avatar asked Oct 02 '15 00:10

Erik Hanson


People also ask

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

Importing CSV file using MySQL Workbench The following are steps that you want to import data into a table: Open table to which the data is loaded. Review the data, click Apply button. MySQL workbench will display a dialog “Apply SQL Script to Database”, click Apply button to insert data into the table.

Which one of the options is correct for import wizard?

The Data Import Wizard makes it easy to import data for many standard Salesforce objects, including accounts, contacts, leads, solutions, campaign members, and person accounts. You can also import data for custom objects. You can import up to 50,000 records at a time.


2 Answers

Verify the encoding of your file. When parsing a source file as UTF-8, the workbench silently bombs out when it encounters non UTF-8 characters. I used cp1250 (windows 1250) for a file exported from Excel and everything worked properly.

like image 184
Taurai Benhura Avatar answered Oct 15 '22 22:10

Taurai Benhura


You need to ensure that your csv options are set correctly when importing the table.

When you get to the below screen notice how red arrow points to the wrench. By clicking that an option drop down to set your line separator, enclosing strings, and field separator will appear. If these are not set right then the data will load unsuccessfully.

enter image description here

Below is a sample CSV file. Notice how in Notepad++ the wrapper button is pressed so you can see the end of line. In this case the end of line is CR LF. The default option for Workbench Import wizard is just LF. Additionally, default field separator appears to be a ; and not a ,.

enter image description here

You can read more here at dev.mysql

like image 38
BK435 Avatar answered Oct 15 '22 22:10

BK435