I work with lots of administrative data from Scandinavia and often included in the metadata are text strings with "ÅÄÄåäö"-characters. For example, a shapefile with city names.
What I would like to be able to do is search through the attribute table and replace each Å and Ä with A, Ö with o, å and ä with a and ö with o. I know how to do this with 'replace' but my problem is that even having the letters in the script causes an error.
I even replaced the actual letters with the appropriate chr-value but that didn't work either. Here's just one of many attempts to do this:
# -*- coding: cp1252 -*-
from arcpy import da
import re
fc = r"V:\Indata\tatort_fran_kund_buff200m.shp"
fields = ['TOBETECKN', 'Outname']
with da.UpdateCursor(fc, fields) as cursor:
for row in cursor:
s = row[0]
for ch in s:
if ch == chr(196):
s = s.replace(ch, 'A')
elif ch == chr(197):
s = s.replace(ch, 'A')
elif ch == chr(214):
s = s.replace(ch, 'O')
elif ch == chr(228):
s = s.replace(ch, 'a')
elif ch == chr(229):
s = s.replace(ch, 'a')
elif ch == chr(246):
s = s.replace(ch, 'o')
row[1] = s
cursor.updateRow(row)
Nothing I've tried works. In this example, the script worked but ignored the actual vowel replacement and returned the same text (with the old vowels). Any and all help is appreciated but please do not suggest that I read up on unicode or anything like that (I've been googling this for weeks w/o success).