title: find and replace a string in all text files from Excel sheet
body: <p>I need to import excel to a dictionary and then using the dictionary to find and replace strings in all SQL files in a folder.</p>
  <p>I tried the below Python code to import from excel to the dictionary.</p>
  <p>Excel input</p>
  <p><a href="https://i.stack.imgur.com/BDjLW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BDjLW.png" alt="enter image description here" /></a></p>
  <pre><code>import pandas as pd
  d = pd.read_excel(r&quot;findrep.xls&quot;,index_col=[0]).to_dict(orient='index')
  print(d)
  </code></pre>
  <p>output for the code is coming as</p>
  <pre><code>{'art': {'rep': 'artist'}, 'car': {'rep': 'cart'}, 'dar': {'rep': 'dart'}}
  </code></pre>
  <p>but I need as follows</p>
  <pre><code>{'src':'rep','art':'artist','car':'cart','dar':'dart'}
  </code></pre>
  <p>then Also I need to replace all the files in a folder, I am trying to use the following code, but I am getting 'dict' object has no attribute 'iteritems' error.</p>
  <p>please help..</p>
  <pre><code>import os
  os.chdir(&quot;C:\\Users\\Magesh\\Documents\\Python Scripts\\sql&quot;)
  replacements = {'src':'rep','art':'artist','car':'cart','dar':'dart'}
  
  for files in os.listdir(&quot;.&quot;):
      fo = open(files, &quot;rU&quot;)
      text = fo.read()
      for src, target in replacements.iteritems():
          text = text.replace(src, target)
          fo.seek(0)
          fo.write(text)
          fo.truncate()
          fo.close()
  </code></pre>