Python script to parse a big workbook
<p>I have an extra sized excel file and I need to automate a task I do everyday: Add rows to the bottom with the day's date, save a new workbook, crop the old ones and save as a new file with the day's date.</p>

<p>An example is today only having rows with date 04-10-2016 and the filename would be <code>[sheetname]04102016H12</code> or <code>[sheetname]04102016H16</code>if it has passed 12 pm.</p>

<p>I've tried xldr, doing this in VBA and so on but I can't get along with VBA and it is slow. So I'd rather use Python here - lightweight, does the job and so on.</p>

<p>Anyway, so far, I have done the follwing:</p>



<pre><code>import xlsxwriter, datetime, xlrd
import pandas as pd

# Parsing main excel sheet to save the correct 

with xlrd.open_workbook(r'D:/path/to/file/file.xlsx', on_demand=True) as xls:
    for sheet in xls.parse(xls.sheet_names([0])):
        dfs = pd.read_excel(xls, sheet, header = 1)
        now = datetime.date.today()
        df[df['Data'] != now]
        if datetime.time()&lt;datetime.time(11,0,0,0):
            df.to_excel(r'W:\path\I\need'+str(sheet)+now+'H12.xlsx', index=False)
        else:
            df.to_excel(r'W:\path\I\need'+str(sheet)+now+'H16.xlsx', index=False)
</code></pre>

<p>Unfortunately, this does not separate the main file into as many files as worksheets the workbook contains. It outputs <code>TypeError: 'list' object is not callable</code>, regarding this <code>in xls.parse(xls.sheet_names([0]))</code>.</p>

<p>Based on comments below I am updating my answer. Just do:</p>

<pre><code>xls.sheet_names()[0]
</code></pre>

<p>However, if you want to loop through the sheets, then you may want all sheet names instead of just the first one.</p>

python excel filtering