Python to Combine Multiple Excel Worksheets into One Worksheet
ramit.prasad at jpmorgan.com
Thu Feb 16 22:06:27 CET 2012
>I have one single Excel file with many separate worksheets, and for work I need to combine all these separate worksheets into one single worksheet (I am not worried about formatting, as the format is the same in each sheet, nor am I worried about Excel's row limit).
>Essentially, I am looking for a way to append the data in one sheet to the bottom of the sheet that proceeds it.
>What would be the best way to do this, and how would I go about doing it? Can it be done simply with the xlwt, xlrd, and xutils modules, or (as I was thinking) do I need to convert the sheets to separate csv files, then append the separate csv files, and then write the completed file back into .xls format? >Or perhaps something else?
>As I am really only a Python beginner, any and all help is very much appreciated. Thank you in advance!!
Read the data from the different worksheets using xlrd and then use xlwt to write to a single worksheet in a new excel file. The csv option is probably not useful since it will just add an intermediary step unless you are converting outside of python (i.e. manually).
Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423
This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.
More information about the Python-list