I have an Excel file containing a varying number of columns, I would like to loop through certain columns (from their header row value) of that file using Python, then write (copy) those columns to another Excel file.
Any examples on how I can do this please?
Here are some options to choose from:
If you need to copy only data (without formatting information), you can just use any combination of these tools for reading/writing. If you have an
xls
file, you should go with xlrd+xlwt option.Here's a simple example of copying the first row from the existing excel file to the new one: