Pandas/excel Get sheet name Modify data multiple sheet rows The column column sorted by one output

Source: Internet
Author: User
Tags glob

1 #-*-coding:utf-8-*-2 3 ImportSYS4 ImportGlob5 ImportOS6  fromXlrdImportOpen_workbook7 ImportXLWT8 ImportPandas as PD9  fromXlutils.copyImportCopyTen ImportNumPy as NP One  A Reload (SYS) -Sys.setdefaultencoding ("Utf-8" ) -  the  - defWrite_sheet (path,excel_name,name,index): -DF =Pd.read_excel (path,name) -list_sheet=[] +      forNumberinchRange (0,len (df[0:])): -          forIinchDf[0:].iloc[number]: + list_sheet.append (str (i)) A  at     PrintList_sheet -rb=Open_workbook (excel_name) -wb=copy (RB) -Ws=Wb.get_sheet (Index) -Number=0 -      forIinchList_sheet: in ws.write (number,0,i) -Number=number+1 to Wb.save (excel_name) +  - defSet_excel (excel_name,sheet_list): theI=0 *      forNameinchsheet_list: $         ifi==0:Panax Notoginsengbook=XLWT. Workbook () - book.add_sheet (name) the Book.save (excel_name) +I=i+1 A         Else: thesrc = Open_workbook (excel_name,formatting_info=True) +Destination =copy (SRC) - destination.add_sheet (name) $ Destination.save (excel_name) $ defMain (): -Homdir=OS.GETCWD () -Sour_dir=os.path.join (Homdir,"QCZSL") thePath_dir=os.path.join (Sour_dir,"*") -      forPathinchGlob.glob (path_dir):WuyiExcel_name=path.split ("\\") [ -1].strip ("x") thesheet_list=Open_workbook (path). Sheet_names () - Set_excel (excel_name,sheet_list) Wu          forNameinchsheet_list: -index=Sheet_list.index (name) About Write_sheet (Path,excel_name,name,index) $             Print "##########" -  - if __name__=="__main__": -Main ()

Pandas/excel Get sheet name Modify data multiple sheet rows The column column sorted by one output

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.