问题描述
目前,我在代码中传递文件名时使用参数。
用法:
!python C:/Users/sindhus/Desktop/Fio/fio_mergefiles.py 1.log 2.log 3.log .......n output.csv
我使用的代码如下。下面代码中的“读者”我用它来传递其他功能。
debug = False
argv = ['']+['f%02d'%n for n in range(1,n)]+[''] if debug else argv
out = stdout if debug else open(argv[-1],'w')
readers = [reader(open(f),n) for n,f in enumerate(argv[1:-1])]
N = len(readers)
print('Interval',*('IOPS%02d'%(n+1) for n in range(N)),sep=',',file=out)
# initialize for the loop
t0 = ""
# the loop
for t,iops,extra1,extra2,n in merge(*readers,key=lambda x:int(x[0])):
if t != t0:
if t0: print(t0,*iops_l,file=out)
t0 = t
iops_l = ['····' if debug else '']*N
iops_l[n] = '%4s'%iops if debug else iops
现在我打算将所有输入文件保留在文件夹中,我只想解析目录名称和 output_file 路径。我尝试使用路径列表和 glob dint 帮助很大。
我想要的是
!python C:/Users/sindhus/Desktop/Fio/fio_mergefiles.py C:/Users/data/ C:/Users/output/output.csv
我已经编辑了我的代码,因为他们中的大多数人都想要“readers”参数返回的内容。 提前致谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)