title: How to translate in python using whole words as keys
body: <p>I have a table that contains tokens and their translations separated by an '=' (a line of it would be 'ACTION_PLAN=Action Plan'). I need to parse another file and substitute all the tokens for these values.</p>
  
  <p>I managed to create a dict that has all tokens as keys and the phrases as values with the following code:</p>
  
  <pre><code>with open(dictionaryFileName) as d:
      commands = dict(line.split('=', 1) for line in d)
  </code></pre>
  
  <p>And it does what I intended, a dict with 'TOKEN:Phrase'</p>
  
  <p>However, I now need to use this dict to substitute all the tokens in another file (a csv).</p>
  
  <p>This file goes like 'ACTION_PLAN,GROUP_ANALYTICAL_MAP_REPORT,READ', every comma exactly one token, so I tried doing the following:</p>
  
  <pre><code>data = pd.read_csv(permissionFileName)
  
  data["module_name"] = data["module_name"].str.translate(commands)
  
  print(data)
  </code></pre>
  
  <p>where "module_name" is the name of the first column. </p>
  
  <p>But it just returns exactly the same, no change at all and no exceptions either. I did some research and found that the dict needs to have unicode characters as keys, anyway to work around this other than creating the method myself?</p>
  
  <p>Expected for this specific block of code:
  input</p>
  
  <pre><code>module_name, group_name, perm_name
  ACTION_PLAN,GROUP_ANALYTICAL_ACTION_PLAN_REPORT,READ
  ACTION_PLAN,GROUP_ANALYTICAL_MAP_REPORT,READ
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>Action Plan,GROUP_ANALYTICAL_ACTION_PLAN_REPORT,READ
  Action Plan,GROUP_ANALYTICAL_MAP_REPORT,READ
  </code></pre>
  
  <p>dictionary:</p>
  
  <pre><code>ACTION_PLAN=Action Plan
  </code></pre>