Search code examples
phpmysqlcsvutf-8

importing CSV file to mysql, there is in persian(utf-8) formate text


Structure of mysql table:

id-----int
name---var-----utf8_persian_ci

after saveing the EXCEL file as a file.csv and importing it from phpmyadmin it's showing the text in database like:

????? ??? ???? 䟪? 㠧?驥

even my mysql formate is in utf8, here when i save the text in csv and if i open csv file in notepad still it's like:

????? ??? ???? 䟪? 㠧?驥

how i can keep it work in utf8, regards in advacen


Solution

  • For persian excel files on importing it to mysql,

    file name = file1.xls

    1- the database table columns should support utf8-persian-ci
    2- save .xls fiel as **Unicode Text(.txt)**--file1.txt
    3- open file1.txt (now replace tab(space) to comma(,)
         you can do it by search and replace just copy the tab(space) and replace with comma(,)
    4- after replaceing tab to comma , **save as** file as file1.csv 
       on encodeing--select utf-8
    
    
    4- open phpmyadmin ,create database ,create table(same column) 
    5- chose file1.csv
    6- run import 
    

    here you are done. NOTE: the column of your table in database should be same as column in file1.csv

    regards