import pandas as pd
import numpy as np
import re
import csv
import os
path=os.getcwd()+"/10000000/checkres/"
fiels=os.listdir(path)
bdlist=[]
for filename in fiels:
s=re.findall(".*?bdinfo.csv", str(filename), re.S)
if len(s)>0:
print(s)
temppath = os.path.join(path,s[0])
bdtemp=pd.read_csv(temppath)
columns=['index','id']
bdtemp.columns=columns
print("总数:{}".format(bdtemp.count()[0]))
print(bdtemp.columns)
bdtempid=bdtemp['id'].tolist()
bdlist.extend(bdtempid)
print(len(bdlist))
print(bdlist)
data = pd.DataFrame(bdlist)
tname = "bddelet-"+str(len(bdlist))+".csv"
data.to_csv(path+tname)
循环读取某一类文件,将结果追加到新的列表生成Excel
最新推荐文章于 2022-12-28 11:57:36 发布