import xlrd import xlwt import numpy as np import sys def write(): data = xlrd.open_workbook('data.xls') file = xlwt.Workbook() for si,sheet in enumerate(data.sheets()): values = sheet.col_values(0) if values: print(values) table = file.add_sheet('sheet'+str(si+1)) d = ((ri,ci,c) for ri,r in enumerate(np.array(values).reshape(len(values)//7,7)) for ci,c in enumerate(r)) for msg in d: m = list(msg) table.write(m[0],m[1],m[2]) file.save('newdata.xls') if __name__ == '__main__': # write(sys.argv[1]) write()
转换如图:
将数据 转换成
源码链接:http://pan.baidu.com/s/1i4SaWLn 密码:ywva