a plurality of read and write pandas excel sheet form

A reading single form

PD PANDAS AS Import 

excel_reader = pd.ExcelFile ( ' file .xlsx ' ) # specified file sheet_names = excel_reader.sheet_names # reads the file names of all forms, to obtain a listing df_data = excel_reader.parse (SHEET_NAME = sheet_names [I]) # Read SUMMARY take the form, i is the index of the form name, equivalent to pd.read_excel ( 'file .xlsx', sheet_name = sheet_names [i ])

Second, form a plurality of write

import pandas as pd
= pd.ExcelWriter excel_writer ( ' file .xlsx ' )   # define writer, select the file (may be absent) 
df.to_excel ( ' excel_writer, SHEET_NAME = ' custom SHEET_NAME ' , index = False ' )   # written to the specified form 
excel_writer .save ()   # save the file 
excel_writer.close ()   # Close writer

 

Guess you like

Origin www.cnblogs.com/jaysonteng/p/12240823.html