import pandas as pd
import pymysql,emoji,sys,requests
import re,sys,time,pymysql
import configparser
import xlrd #导入模块
from xlutils.copy import copy
#导入模块
#wb = xlwt.Workbook(encoding = 'ascii') #创建新的Excel(新的workbook),建议还是用ascii编码
file1="keaa.xlsx"
file2="kea.xls"
#file2="book1.xls"
rb = xlrd.open_workbook(file2)
wb=copy(rb)
ws=wb.get_sheet("Sheet2")
class DoExcela:
def do_alldata(self,filename,sheetname,head=0):#返回列表,列表元素是某行内容
df=pd.read_excel(filename,sheetname,header=head,engine='openpyxl',date_parser=lambda x: pd.to_datetime(x, format='%Y年%m月%d日'))
lb=[]
lba=[]
for i in df.values:
lb.append(i)
#lba=lb.reverse()
return lb
af=DoExcela()
ab=0
sqlstr=[]
ap=[]
cf = configparser.ConfigParser()
ac=cf.read("mydz.ini")
#ws = wb.add_sheet(file2)
abb=0
for aa in af.do_alldata(file1,sheetname='Sheet2',head=0):
time.sleep(0)
result=[]
abb=abb+1
ida=str(aa[0])
sql=f'select * from dza where id='+str(ida)
abc=''
au=0
for ii in aa:
au=au+1
if au<=2:
continue
try:
ab=str(int(ii))
except:
ab="0"
if ab=="":
ab="0"
if abc=="":
abc=ab
else:
abc=abc+","+ab
print(abc)
ws.write(abb,1,abc)
wb.save("mm.xls")
sys.exit(0)