|
发表于 2022-4-14 08:17:59
|
显示全部楼层
回帖奖励 +10 鱼币
10个文件,能不能试试多线程去读呢,- def concat_file():
- with concurrent.futures.ThreadPoolExecutor() as executor:
- # with concurrent.futures.ProcessPoolExecutor() as executor:
- f_451 = executor.submit(read_txt,path_45_1,'45-1')
- f_452 = executor.submit(read_txt,path_45_2, '45-2')
- f_651 = executor.submit(read_txt,path_65_1, '65-1')
- f_120 = executor.submit(read_txt,path_120, '120')
- f_ws = executor.submit(read_txt,path_wenshui, '温水')
- f_1501 = executor.submit(read_txt,path_150_1, '150-1')
- f_1502 = executor.submit(read_txt,path_150_2, '150-2')
- df_451 = f_451.result()
- df_452 = f_452.result()
- df_651 = f_651.result()
- df_120 = f_120.result()
- df_ws = f_ws.result()
- df_1501 = f_1501.result()
- df_1502 = f_1502.result()
- df = pd.concat([df_451,df_452,df_651,df_120,df_ws,df_1501,df_1502])
复制代码 |
|