Data that is stored in an Excel file as follows:

Date ID Name var1 var2 var3 commit 2019-05-10 123 Abc * * * 32szx 2019-05-06 123 Abc * * * 32szx 2019-05-06 123 Abc * * * 32szx 2019-05-06 123 Abc * * * 32szx 2019-05-04 123 Abc * * * 32szx 2019-05-03 123 Abc * * * 32szx 2019-05-01 123 Abc * * * 32szx 2019-05-10 123 Abc * * * 32szx 2019-05-06 123 Abc * * * 32szx 2019-05-06 123 Abc * * * 32szx 2019-05-06 123 Abc * * * 32szx 2019-05-04 123 Abc * * * 32szx 2019-05-03 123 Abc * * * 32szx 2019-05-01 123 Abc * * * 32szx 

It is necessary to obtain such a table only in HTML using Python.

The peculiarity is that when data changes constantly. In the example data above, it is necessary to condition the rows for the current day.

This HTML table will be inserted into the letter and sent to users.

Prompt, in what type it is necessary to import from an eksel into a python? And how to make an automatically resizable template ... thanks for any help.

    1 answer 1

    Use the Pandas module:

     import pandas as pd # pip install pandas df = pd.read_excel(r'/path/to/file.xlsx', parse_dates=['Date']) mask = df['Date'].dt.floor('D') == pd.to_datetime('today').floor('D') df[mask].to_html(r'/path/to/file.html', index=False) 

     <table border="1" class="dataframe">\n <thead>\n <tr style="text-align: right;">\n <th>Date</th>\n <th>ID</th>\n <th>Name</th>\n <th>var1</th>\n <th>var2</th>\n <th>var3</th>\n <th>commit</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>2019-05-06</td>\n <td>123</td>\n <td>Abc</td>\n <td>*</td>\n <td>*</td>\n <td>*</td>\n <td>32szx</td>\n </tr>\n <tr>\n <td>2019-05-06</td>\n <td>123</td>\n <td>Abc</td>\n <td>*</td>\n <td>*</td>\n <td>*</td>\n <td>32szx</td>\n </tr>\n <tr>\n <td>2019-05-06</td>\n <td>123</td>\n <td>Abc</td>\n <td>*</td>\n <td>*</td>\n <td>*</td>\n <td>32szx</td>\n </tr>\n <tr>\n <td>2019-05-06</td>\n <td>123</td>\n <td>Abc</td>\n <td>*</td>\n <td>*</td>\n <td>*</td>\n <td>32szx</td>\n </tr>\n <tr>\n <td>2019-05-06</td>\n <td>123</td>\n <td>Abc</td>\n <td>*</td>\n <td>*</td>\n <td>*</td>\n <td>32szx</td>\n </tr>\n <tr>\n <td>2019-05-06</td>\n <td>123</td>\n <td>Abc</td>\n <td>*</td>\n <td>*</td>\n <td>*</td>\n <td>32szx</td>\n </tr>\n </tbody>\n</table> 

    • sorry, in eksel there is more data. which are clipped using a python. Is it possible, as when importing to html, to view them under certain conditions? For example in this case by date - WilteRatenau
    • @WilteRatenau, in Pandas, all this is done quite simply. Give a small reproducible example of data (in such a way that the data can be copied) in the question and what you want to get on the output. What is the most effective way to ask a question related to the processing and / or analysis of data (for example: by Pandas / Numpy / SciPy / SciKit Learn / SQL)? - MaxU
    • Corrected the data. In this version is suitable? - WilteRatenau
    • As well as the moment that this table should be inserted into a specific piece of text is already ready html - WilteRatenau
    • @WilteRatenau, about "эта таблица должна быть вставлена в опредёленный кусок текста уже готово html" - this is already those. task for freelancing, but not a question for SO;) - MaxU