Why can I import my float as VARCHAR only?

Hi everyone,
I’m an SQL beginner. Currently, I’m trying to import CSV data to a MySQL table in MAMP. I’m using the provided import function.
These are the first lines of my CSV file:

"id","stop_name","latitude","longitude"
8012713,"Rangsdorf, Bahnhof",52.294125,13.431112
8010205,"Leipzig, Hauptbahnhof",51.344817,12.381321
8010327,"Senftenberg, Bahnhof",51.52679,14.003977

The problem is the data in the latitude/longitude columns. The floats always are between 6 and 7 digits long.
I can import all rows of the CSV (33.870 entries) to the table, but only as long as I declare each column as type “VARCHAR”.

If I try to import the data as FLOAT, DECIMAL or DOUBLE, I get an error. Whether I specify the (m,n) length or not.

Any ideas anyone?

In case anyone runs into the same error:
I created the empty table before importing the CSV file. If a CSV file is imported without an already existing table there is the possibility to check a checkbox saying like: “If checked the first line will be interpreted as header and won’t be imported”.
If the CSV will be imported into an existing table with all data types set in advance, the line with this checkbox isn’t there and the header has to be removed from the CSV file.
I hadn’t removed the header and so it was interpreted as regular data and collided with the data types INT, DOUBLE and DECIMAL.

4 Likes