Last active
January 31, 2023 15:10
-
-
Save rsperl/9ec31b863fad46ace499a387e30a4333 to your computer and use it in GitHub Desktop.
Reading excel files with python and panda #snippet
This file contains 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
#!/usr/bin/env python | |
# src: http://pandas.pydata.org/pandas-docs/stable/io.html#io-excel-reader | |
import pandas as pd | |
# get a dataframe from xlsx object | |
xlsx = pd.ExcelFile('path_to_file.xls') | |
df = pd.read_excel(xlsx, 'Sheet1') | |
# get dataframe from context object | |
with pd.ExcelFile('path_to_file.xls') as xls: | |
df1 = pd.read_excel(xls, 'Sheet1') | |
df2 = pd.read_excel(xls, 'Sheet2') | |
# examples of manipulating dataframes | |
# http://code-love.com/2017/04/30/excel-sql-python/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment