Select to view content in your preferred language

replace accented characters with the field calculator

2379
2
Jump to solution
05-15-2020 04:38 PM
RTMRTM
by
Emerging Contributor
I need to replace all the special characters in a field.

I am using the replace function, but it gives me an error
!Nombre_Cli! .replace("áéíóúñ#/,","aeioun   ")
 
0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

From

What is the best way to remove accents in a Python unicode string? - Stack Overflow 

oefe's response

z = "áéíóúñ#/"  # ---- an example

import unicodedata
def strip_accents(s):
   return ''.join(c for c in unicodedata.normalize('NFD', s)
                  if unicodedata.category(c) != 'Mn')
                  

strip_accents(z)  # ---- example output
'aeioun#/'

... sort of retired...

View solution in original post

2 Replies
DanPatterson
MVP Esteemed Contributor

From

What is the best way to remove accents in a Python unicode string? - Stack Overflow 

oefe's response

z = "áéíóúñ#/"  # ---- an example

import unicodedata
def strip_accents(s):
   return ''.join(c for c in unicodedata.normalize('NFD', s)
                  if unicodedata.category(c) != 'Mn')
                  

strip_accents(z)  # ---- example output
'aeioun#/'

... sort of retired...
JoshuaBixby
MVP Esteemed Contributor

RTM RTM‌, it appears Dan's reply answered your question.  If so, please mark it correct to close out the question.  If not, what didn't work?

0 Kudos