title: iterating new pandas dataframe to a new excel sheet in the same workbook
body: <p>I'm attempting to create a web scraper that that get information of a similar table (with different values) from multiple pages (though in my case it's scrapping html stored in text documents)</p>
  
  <p>The following code is a snippet from my program where a data frame is made from a previously made list along with the header. It then opens a new excel workbook and writes the data frame to the workbook in a worksheet with a specified name (which changes with each iteration)</p>
  
  <pre><code>import os
  from bs4 import BeautifulSoup # imports BeautifulSoup
  import pandas # imports pandas
  from pandas import ExcelWriter
  
  #creates the lists
  list_of_rows = []
  list_of_lists = []
  list_of_headers = []
  
  for File in range(len(os.listdir())):
      if os.listdir()[File].endswith('.txt'):
          file = open(os.listdir()[File])
          data = file.read()
          file.close()
  
          #Converts the text file into something the program can use
          soup = BeautifulSoup(data,'lxml')
          tables = soup.find_all(class_="overthrow table_container") #Creates a resutset that will show all of the tables with this class name
  
          #grabs from the header
          find_header = tables[2].thead
          header = find_header.find_all("th")
  
          #grabs from the table
          find_table = tables[2].tbody #creates a tag element from the desired table and highlights the tbody section
          rows = find_table.find_all("tr") #creates another resultset signle out the elements with a tr ta
  
          #for loop that creates the list for the header
          header_list = []
          for i in range(len(header)):
              if i &lt; 14:
                  pass
              else:
                  list_of_headers.insert(i,header[i].get_text())
  
          #for loop that creates the lists for data frame table
          for j in range(len(rows)):
              row_finder = rows[j]
              tag_row = row_finder.find_all("td")
              for i in range(len(tag_row)):
                  list_of_rows.insert(i,tag_row[i].get_text())
              list_of_lists.append(list_of_rows)
              list_of_rows = []
  
          #creates the DataFrame
          df = pandas.DataFrame(list_of_lists,columns=list_of_headers)
  
          writer = ExcelWriter('testing document.xlsx', engine='xlsxwriter')
          df.to_excel(writer,sheet_name=os.listdir()[File])
          writer.save()
          df.drop(df.index)
          print("worked once")
  
      else:
          pass
  </code></pre>
  
  <p>and I get the following error code.</p>
  
  <pre><code>worked once
  Traceback (most recent call last):
    File "test3.py", line 47, in &lt;module&gt;
      df = pandas.DataFrame(list_of_lists,columns=list_of_headers)
    File "C:\Python3.6\lib\site-packages\pandas\core\frame.py", line 314, in __init__
      arrays, columns = _to_arrays(data, columns, dtype=dtype)
    File "C:\Python3.6\lib\site-packages\pandas\core\frame.py", line 5617, in _to_arrays
      dtype=dtype)
    File "C:\Python3.6\lib\site-packages\pandas\core\frame.py", line 5696, in _list_to_arrays
      coerce_float=coerce_float)
    File "C:\Python3.6\lib\site-packages\pandas\core\frame.py", line 5755, in _convert_object_array
      'columns' % (len(columns), len(content)))
  AssertionError: 56 columns passed, passed data had 28 columns
  </code></pre>
  
  <p>So between the first line printing the code "this worked once" and the fact that it does, in fact, create the excel file, my guess is the problem is it's not creating a new worksheet? THough this code could not be doing at all what I think it is. </p>