title: Writing list to excel using openpyxl
body: <p>Newer to Python, brand new to openpyxl - I have a large text file that I used regexs to extract the data I need - now I need to write that data to an excel file with openpyxl. The text file is a network address translation (NAT) table which looks like </p>
  
  <pre><code>src_adtr:10.20.30.40 dst_adtr:185.50.40.50 src_adtr_translated:70.60.50.40 dst_adtr_translated:99.44.55.66
  </code></pre>
  
  <p>These four elements would be one row of the excel file (I have about 500 rows that need to be written).</p>
  
  <p>When I run the code, I do not get any errors, but it also does nothing - how can I correct this?</p>
  
  <pre><code>import re
  import openpyxl
  
  with open("NAT-table.txt", "r") as f:
      text = f.read()
  
  source = re.findall(r':src_adtr\s+.*\s+.*\s+:Name\s+[\(](.*)', text)
  dest = re.findall(r':dst_adtr\s+.*\s+.*\s+:Name\s+[\(](.*)', text)
  source_adtr = re.findall(r':src_adtr_translated.*\s+.*\s+.*\s+.*\s+.*\s+.*\s+:Name\s+[\(](.*)', text)
  dest_adtr = re.findall(r':dst_adtr_translated\s+.*\s+.*\s+.*\s*\s+.*\s+.*\s.*\s+:Name\s+[\(](.*)', text)
  firewall = re.findall(r'\w+LINT\d+(?!_)', text) #'\w' includes the '_'(underscore) char
  
  natRules = list(zip(source, dest, source_adtr, dest_adtr, firewall))
  wb = openpyxl.load_workbook('NAT-table.xlsx')
  sheet = wb.active
  for i in range(2, sheet.max_row):
      for k in range(1, 5):
          for t in natRules:
              sheet.cell(row=i, column=k).value = natRules[i][k]
          #sheet.cell(row=rowNum, column=1).value = i
  
  wb.save('NAT-table.xlsx')
  </code></pre>