pandas EXCELデータの読み出しと書き込み
1010 ワード
import pandas as pd
def write_excel(path,data):
writer=pd.ExcelWriter(path)
for k,v in data.items():
v.to_excel(writer,k,index=False,header=None)
def read_excel1(path):
data_xls = pd.ExcelFile(path)
print(data_xls.sheet_names)
data={}
for name in data_xls.sheet_names:
df=data_xls.parse(sheetname=name,header=None)
data[name]=df
# print(df)
# print(name)
return data
def read_excel2(path):
data_xls = pd.io.excel.ExcelFile(path)
data={}
print(data_xls.sheet_names)
for name in data_xls.sheet_names:
df=pd.read_excel(data_xls,sheetname=name,header=None)
data[name]=df
# print(df)
# print(name)
return data
if __name__ == '__main__':
path="F:\Code\Python\DataAnalyse\pandasTest\mydate.xlsx"
data=read_excel(path)
path_desc="F:\Code\Python\DataAnalyse\pandasTest\mydate_target.xlsx"
write_excel1(path_desc,data)