Last active
October 11, 2021 15:53
-
-
Save nsuvorov83/45a89c679326719be140022911c266b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from openpyxl import load_workbook | |
| import pandas as pd | |
| def load_df_table(filename, worksheet, tablename): | |
| wb = load_workbook(filename) | |
| ws = wb[worksheet] | |
| dfs = {} | |
| for table_name, value in ws.tables.items(): | |
| table = ws[value] | |
| header, *body = [[cell.value for cell in row] | |
| for row in table] | |
| df = pd.DataFrame(body, columns=header) | |
| if table_name == tablename: return df | |
| return None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment