Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

ArcPy and File Geodatabase Character Encoding

$
0
0

I have a JSON file containing special characters, which can be represented in Unicode. However, as soon as I export that JSON file to a file geodatabase using arcpy, the special characters all “break,” i.e., they come out as something different. A Google search tells me (via this table listing string representations of special characters) that the character I’m having a problem with in my sample dataset is in UTF-8/Latin-1.

The code I’m using for this is:

arcpy.JSONToFeatures_conversion(jsonFileName, os.path.join(fgdbPath, outputName))

I have also specified the encoding for the Python (2.7) file via:

import sys
reload(sys)
sys.setdefaultencoding('utf-8')

I have also varied the above with “latin-1″ and various other specifications for the encoding, mostly experimentally as I have little experience with encoding.

But regardless, where the content of my JSON file is for example “Búzi”, the content of my feature (exported to an FGDB) will be “Búzi”.

Nowhere can I find out about a parameter to pass to JSONToFeatures_conversion, or to CreateFileGDB_management (where I create the FGDB in question), or an Arc environment variable to set, which will allow me to specify the desired encoding.

How do I export to FGDB with the desired encoding (or providing the desired result by whatever means)?


Viewing all articles
Browse latest Browse all 767

Trending Articles