title: Python read excel colum, search in xml and if found replace with value in excel second column
body: <p>I´m migrating a website from .net to wordpress. I need to merge 2 files so I can import all posts information to Wordpress.</p>
  <p>I have 2 files:</p>
  <p>a. XLSX file with 2 colums. A = Id of post and B URL to mp3 file.
  b. XML file with the posts information.</p>
  <p>I´m trying to create a python code that reads a value from a XLSX file on column A and if found in a XML file, then replace it with the value of XLSX column B of the same row.</p>
  <p>1- this code works if xml file is short, but the in the actual xml with 2 million lines fails, and some times its empty.</p>
  <p>2 - Also when it works, the values get inside the the actual xml structure, but without order. Maybe if possible, I´ll like that when the value is found on the XML, go to the end of line and append the value with the  tags in the next line.</p>
  <p>I need a clean structure so I can import this XML to wordpress.</p>
  <pre><code>import pandas as pd
  
  
  id = ()
  link = ()
  lines = []
  df = pd.read_excel('C:/TEMP/PAnamaIds_prueba.xlsx')
  
  for index, row in df.iterrows():       # Reads xlsx file row by row..
      id = str(row[&quot;iD&quot;])                # Store read id..
      link = row[&quot;Url&quot;]                  # Store read URL..
      replacement = &quot;&quot;
  
      with open(&quot;C:/TEMP/XML_RP_TEST_2.xml&quot;, &quot;r&quot;, errors='ignore') as file:
          for line in file:
              line = line.strip()
              changes = line.replace(id, &quot;&lt;mp3&gt;&quot; + link + &quot;&lt;/mp3&gt;&quot;)
              replacement = replacement + changes + &quot;\n&quot;
  
          file.close()
  
          wr = open(&quot;C:/TEMP/XML_RP_TEST_2.xml&quot;, &quot;w&quot;)
          wr.write(replacement)
          wr.close()
  </code></pre>