From now on, read Excel files.
There is also a version that reads CSV files.
# import lib
import pandas as pd
# read xlsx file
xlsFile = "hoge.xlsx"
sheetName = "hoge1"
xls_data = pd.read_excel(xlsFile, sheetname=sheetName)
print(xls_data)
# import lib
import pandas as pd
# read csv file
csvFile = "fuga.csv"
csv_data = pd.read_csv(csvFile, encoding='utf-8')
print(csv_data)
Column specification
xls_data = pd.read_excel(xlsFile, sheetname="hoge1", parse_cols="A:H")
Line specification
xls_data = pd.read_excel(xlsFile, sheetname="hoge1", skiprows=0, skip_footer=5)
If you want to specify a matrix, you can specify both. It would be nice if it could be specified like ʻA1: H5`, but isn't it possible?
Recommended Posts