from joblib import Parallel, delayed
import time
#make a function that takes ONE filename and processes it the way you want
def process_csv(filename):
count = 0
#open file using method of choice plain file or csv
f = open(filename)
for line in f:
#do we ignore header?
if count == 0:
count += 1
continue
arr = line.strip().split(',')#use csv module if not simple text
#do something, store it, whatever
if count % 10 == 0:
time.sleep(5)
return 1
if __name__ == '__main__': #windows-only protection
filenames = ['file1', 'file2', ..., 'file10']
dummy = Parallel(n_jobs=10)(delayed(process_csv)(fn) for fn in filenames)
我想试试joblib 下面是一些未经测试的示例代码。。。你知道吗
现在,请注意,如果有人在您读取这些文件时添加到这些文件中…此代码可能无法工作。你知道吗
相关问题 更多 >
编程相关推荐