# -*- coding: utf-8 -*-
import xlrd
from time import strftime
wb = xlrd.open_workbook(r"D:\商品编码excel模板.xlsx")
#得到第一张表
sh = wb.sheet_by_index(0)
spbm_head = '{商品编码}[分隔符]"~~"'+'\n'+'// 每行格式 :'+'\n'+'// 编码~~名称~~简码~~商品税目~~税率~~规格型号~~计量单位~~单价~~含税价标志~~隐藏标志~~中外合作油气田~~税收分类编码~~是否享受优惠政策~~税收分类编码名称~~优惠政策类型~~零税率标识~~编码版本号'+'\n'
filename = strftime('%Y%m%d%H%M%S')+'_商品编码.txt'
with open(filename, 'w') as f:
f.writelines(spbm_head)
for row in range(1, sh.nrows):
val = sh.row_values(row)
print(type(val),id(val))
f.writelines('~~'.join(str(e) for e in val)+'\n')
import xlrd
from time import strftime
wb = xlrd.open_workbook(r"D:\商品编码excel模板.xlsx")
#得到第一张表
sh = wb.sheet_by_index(0)
spbm_head = '{商品编码}[分隔符]"~~"'+'\n'+'// 每行格式 :'+'\n'+'// 编码~~名称~~简码~~商品税目~~税率~~规格型号~~计量单位~~单价~~含税价标志~~隐藏标志~~中外合作油气田~~税收分类编码~~是否享受优惠政策~~税收分类编码名称~~优惠政策类型~~零税率标识~~编码版本号'+'\n'
filename = strftime('%Y%m%d%H%M%S')+'_商品编码.txt'
with open(filename, 'w') as f:
f.writelines(spbm_head)
for row in range(1, sh.nrows):
val = sh.row_values(row)
print(type(val),id(val))
f.writelines('~~'.join(str(e) for e in val)+'\n')
评论
发表评论