Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep special characters when importing into mysql from csv

Tags:

import

mysql

csv

I have a csv file which contains special characters. However, when I import them into my table they do not import. I have the row that needs to contain special characters setup as utf8_general_ci

However, I am losing the special characters upon phpmyadmin import. For example, the degree symbol is not importing. I viewed my csv file in a text editor and it does contain the special characters.

Please help.

Ok, I figured how to do this. See my answer below.

like image 394
MagentoMan Avatar asked Jan 20 '14 19:01

MagentoMan


People also ask

Can a CSV file have special characters?

So if you're working with CSV, what special characters are actually supported? Technically, all of them! There are no specified limits of what characters can be used in a CSV file.

How do I import a CSV file into MySQL?

In the Format list, select CSV. Changing format-specific options. If the csv file is delimited by a character other than a comma or if there are other specifications to the csv files, we can change it in this portion. Click Go to start importing the csv file and the data will be successfully imported into MySQL.


2 Answers

Only needs change the charset in mysql when try to upload the file. In my case works the charset windows-1252

Charset on mysql

like image 98
Raugaral Avatar answered Oct 16 '22 00:10

Raugaral


Ok,

for anyone who has this same issue trying to keep the exported csv file in utf8 while keeping the special characters do the following.

Open up your file in OpenOffice Calc. When you get ready to save it save it as text csv file. While exporting it will ask you what format to save it as. Save it as UTF8 and presto. It does not convert your special characters like excel does.

Hope that helps someone else.

like image 31
MagentoMan Avatar answered Oct 15 '22 23:10

MagentoMan