Tuesday 25 December 2018

export - Exporting from Excel to csv and import in QGIS retaining encoding/special characters (with workaround)?


Problem: When exporting Turkish character encoding into a csv file from an Excel Table (Excel 2013) as a source file I can´t import the resulting csv into QGIS to still displaying the characters correctly . I´m using: "Add Layer" - "Add Delimited Text Layer" and it doesn´t work no matter whether I use as encoding option "UTF-8" or "System".


Result is always: enter image description here


This is possibly rather an excel problem since the problem concerns exporting from Excel. If anyone has any suggestion that would be great, otherwise anyone else reading this with the same problem could try the following workaround.


One possible workaround I use is using Access as an in-between-step:



Importing the Excel-Table into Access retains the special characters. Exporting from Access into a txt or csv file you have the special button called "Advanced options" in the lower left of the export window where you can specify the Encoding of the resulting exported file. If I use "UTF-8" here and then import the resulting csv or txt file into QGIS selecting "Encoding "UTF-8" everything works fine.


Another Question on this site concerns exporting the other way round: Exporting from QGIS to Excel retaining special characters, see here: Export shapefile with "non standard" characters to csv and read in excel


So how do I get Excel to export the characters correctly for QGIS to read them?


My System is Windows 7 Professional 64-bit (6.1, Build 7601) Service Pack 1
Language: German (Regional Setting: German)


QGIS Version is 2.12.0 since I haven´t had time to upgrade.



Answer



Have you tried using Notepad as an in-between-step? After creating your excel file, copy everything in a notepad file, then choose "save as". Make sure that you change the type of file as "All files", then the name of your file must be prompted like "name.csv". (you must use " " for the filename)


EDIT: yes, if you copy directly from Excel the data delimiter is "tab"


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...