Using Python, write an Excel file with columns copied from another Excel file -


i have excel file containing varying number of columns, loop through columns (from header row value) of file using python, write (copy) columns excel file.

any examples on how can please?

here options choose from:

if need copy data (without formatting information), can use combination of these tools reading/writing. if have xls file, should go xlrd+xlwt option.

here's simple example of copying first row existing excel file new one:

import xlwt import xlrd  workbook = xlrd.open_workbook('input.xls') sheet = workbook.sheet_by_index(0)  data = [sheet.cell_value(0, col) col in range(sheet.ncols)]  workbook = xlwt.workbook() sheet = workbook.add_sheet('test')  index, value in enumerate(data):     sheet.write(0, index, value)  workbook.save('output.xls') 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -