title: Populate list variables to html code with python
body: <p>I need to create a bunch of individualized e-mail signatures in html from data collected in an Excel file. I need a separate html/txt file as output which populates the data from the excel file to certain places within the html template. I think this should be possible with Python (flask and jinja). However I have hardly knowledge of Python yet and would be greatful for any help. Further information can be found below:</p>
  <p>Project structure:</p>
  <pre><code>/data.xlsx
  /signature.py
    /templates/sig.html
    /output/
  </code></pre>
  <p>Content of my excel file named data.xlsx:</p>
  <pre><code>name  |  name_given  |  mail
  ==========================================
  John  |  Doe         | john.doe@nym.com
  Steve |  Jobs        | steve@nym.com
  </code></pre>
  <p>Content of sig.html:</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;de&quot; xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:v=&quot;urn:schemas-microsoft-com:vml&quot; xmlns:o=&quot;urn:schemas-microsoft-com:office:office&quot;&gt;
  &lt;HEAD&gt;
      &lt;head&gt;
          &lt;some code&gt;
      &lt;/head&gt;
  &lt;/HEAD&gt;
  &lt;body width=&quot;100%&quot; style=&quot;margin: 0; padding: 0 !important; mso-line-height-rule: exactly;&quot;&gt;
      &lt;left role=&quot;article&quot; aria-roledescription=&quot;email&quot; lang=&quot;de&quot; style=&quot;width: 100%; &quot;&gt;
      &lt;!--[if mso | IE]&gt;
      &lt;table role=&quot;presentation&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; width=&quot;100%&quot; &gt;
        &lt;tr&gt;
          &lt;td&gt;
            {{ name }} {{ name_given }}
          &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;
            {{ mail }}
          &lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
      &lt;/left&gt;
  &lt;/BODY&gt;
  &lt;/html&gt;
  </code></pre>
  <p>What should happen now is this: The data from the separate columns of the excel file should be parsed to the html code each row of the excel data is considered one dataset that should result in one individualized html file based on the template above. The resulting html file should be placed into the output folder and can be numbered consecutively.</p>
  <p>What I have so far:</p>
  <pre><code>from flask import Flask, render_template
  import pandas as pd
  
  workbook = pd.read_excel('data.xlsx', usecols='A:C')
  workbook.head()
  
  # print(workbook)
  df = pd.DataFrame(workbook)
  
  name_given = df['name_given'].values.tolist()
  name = df['name'].values.tolist()
  mail = df['mail'].values.tolist()
  
  app = Flask(__name__)
  @app.route('/', methods=['GET'])
  
  # @app.route(&quot;/sig.html/&quot;, methods=['GET'])
  def sig(name=None):
          return render_template('sig.html', name_given=name_given, name=name, mail=mail)
  </code></pre>