Sql 什么';这是去';规范化&x27;红移的字符串?
因为我的文本是葡萄牙语的,所以有很多带有口音和其他特殊字符的单词,比如:“科拉萨昂”、“哈姆布尔”、“圣保罗” 通常,我使用以下函数在Python中处理这些名称:Sql 什么';这是去';规范化&x27;红移的字符串?,sql,string,amazon-web-services,replace,amazon-redshift,Sql,String,Amazon Web Services,Replace,Amazon Redshift,因为我的文本是葡萄牙语的,所以有很多带有口音和其他特殊字符的单词,比如:“科拉萨昂”、“哈姆布尔”、“圣保罗” 通常,我使用以下函数在Python中处理这些名称: from unicodedata import normalize def string_normalizer(text): result = normalize("NFKD", text.lower()).encode("ASCII", "ignore").dec
from unicodedata import normalize
def string_normalizer(text):
result = normalize("NFKD", text.lower()).encode("ASCII", "ignore").decode("ASCII")
return result.replace(" ", "-")
这将用“--”替换空白空间,替换特殊字符并应用小写转换。“coração”一词将变成“coracao”,“圣保罗”将变成“圣保罗”等等。现在,我不确定在红移中最好的方法是什么。我的解决方案是应用多个替换,如下所示:
replace(replace(replace(lower(column), 'á', 'a'), 'ç', 'c')...
尽管这样做有效,但看起来并不是最好的解决方案。有没有一种简单的方法来规范化我的字符串