Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Replacing Letters with Accents

Hi,

 

I have two lists of names that I want to merge. One list used their names with accents (like é) and the other doesn't. Since having the proper names with the accents isn't super important, I decided to replace all of the accented characters to non accented ones so the merge will work (for example every é to a plain e).

 

Is there a quicker way to do this than doing a replace value for every single instance? Because there's about 12,000 rows.

 

Thanks!

 

  • Hey Sean,

     

    probably it is more complicated and I just don't get it because of languages reasons: I would just use the "Replace Values..." in the power bi "edit queries mode". Just right click on "René" > Replace Values. You can even choose columns and just replace é to e. 

    BR

8 Replies

  • Hello,

    You can create a function in powerquery that converts all column. 

    Open a blank query e paste this: 

     

    (Texto as text) =>
    let
        ListAccents = 
    		{
    		{"à","a"},
    		{"á","a"},
    		{"â","a"},
    		{"ã","a"},
    		{"ä","a"},
    		{"è","e"},
    		{"é","e"},
    		{"ê","e"},
    		{"ë","e"},
    		{"ì","i"},
    		{"í","i"},
    		{"î","i"},
    		{"ï","i"},
    		{"ò","o"},
    		{"ó","o"},
    		{"ô","o"},
    		{"õ","o"},
    		{"ö","o"},
    		{"ù","u"},
    		{"ú","u"},
    		{"û","u"},
    		{"ü","u"},
    		{"À","A"},
    		{"Á","A"},
    		{"Â","A"},
    		{"Ã","A"},
    		{"Ä","A"},
    		{"È","E"},
    		{"É","E"},
    		{"Ê","E"},
    		{"Ë","E"},
    		{"Ì","I"},
    		{"Í","I"},
    		{"Î","I"},
    		{"Ò","O"},
    		{"Ó","O"},
    		{"Ô","O"},
    		{"Õ","O"},
    		{"Ö","O"},
    		{"Ù","U"},
    		{"Ú","U"},
    		{"Û","U"},
    		{"Ü","U"},
    		{"ç","c"},
    		{"Ç","C"},
    		{"ñ","n"},
    		{"Ñ","N"}
    		}
    in
        Text.Combine(List.ReplaceMatchingItems(Text.ToList(Texto), ListAccents))
    • DanielCooper's avatar
      DanielCooper
      Regular Visitor

      Hello Denis,

       

      I was hoping you'd be able to help me

       

      Is there a different version of encoding I can use to help me convert the below:

       

      From: Rvt Tekstil Konfeksiyon Sanayi Ve Dış Ticaret Ltd Åžti

      To: Rvt Tekstil Konfeksiyon Sanayi Ve Dış Ticaret Ltd Şti

       

      The target language is Turkish

       

      Any help you can offer would be greatly appreciated

       

      Thank you,

       

      Daniel

  • Hey Sean,

     

    probably it is more complicated and I just don't get it because of languages reasons: I would just use the "Replace Values..." in the power bi "edit queries mode". Just right click on "René" > Replace Values. You can even choose columns and just replace é to e. 

    BR

    • Anonymous's avatar
      Anonymous
      Not applicable

      Ah thanks! For some reason I thought that replace value only worked if you were replacing the whole value.

  • Hi,

    If you want to replace letters with accented versions in a word or sentence, you can use a word processor or text editor that supports special characters. In most word processors, you can insert accented characters by holding down the "Alt" key and typing a specific code on the numeric keypad. For example, to insert an é, you can hold down the "Alt" key and type "0233" on the numeric keypad.

    Another option is to use a tool that provides a virtual keyboard with accented characters. You can use your mouse to click on the desired accented character, and it will be inserted into your document.

    If you want to programmatically replace letters with accented versions in a string, you can use a library or a function that supports character encoding and mapping. For example, in Python, you can use the "unicodedata" library to map characters to their accented versions using the "normalize" and "translate" functions.