【发布时间】:2020-01-23 07:16:38
【问题描述】:
我的程序应该读取约 400.000 个 csv 文件,而且需要很长时间。我使用的代码是:
for file in self.files:
size=2048
csvData = pd.read_csv(file, sep='\t', names=['acol', 'bcol'], header=None, skiprows=range(0,int(size/2)), skipfooter=(int(size/2)-10))
for index in range(0,10):
s=s+float(csvData['bcol'][index])
s=s/10
averages.append(s)
time=file.rpartition('\\')[2]
time=int(re.search(r'\d+', time).group())
times.append(time)
有没有提高速度的机会?
【问题讨论】:
-
您可以使用多线程/子进程来加快处理速度。查看stackoverflow.com/questions/44950893/… 是否有类似问题。