所以我是一家软件公司的 QC,我目前被困在我正在编写的 Python 脚本上,以整理超过 108,00 条错误日志。我要做的是过滤掉来自我们之前和当前版本(分别为 4.1.468 和 4.1.478)的报告。
报告的文件名如下(Mac 报告为 MD,Windows 报告为 WD):
4.1.468MD.OutOfBoundsException.RaiseOutOfBoundsException.1
我的脚本的第一部分起作用,查找并创建文件夹(如果它们不存在)以将所选报告复制到。但实际复制报告从未发生过。
您可以提供的任何建议或指示都会收到很大的帮助。
import os
import shutil
import time
import pprint
import csv
from collections import Counter
path = 'C:\Heavy Logging Reports\Recorded Issues'
names = os.listdir(path)
folder_name = ['468','478']
for x in range(0,2):
if not os.path.exists(path+folder_name[x]):
os.makedirs(path+folder_name[x])
dest1 = 'C:\Heavy Logging Reports\Recorded Issues468'
dest2 = 'C:\Heavy Logging Reports\Recorded Issues478'
for f in names:
if (f[:4].startswith("468WD")):
shutil.copy(path, dest1)
elif (f[:4].startswith("478WD")):
shutil.copy(path, dest2)
print('Finished Moving Files!')
这应该有帮助。
演示:
import os
import shutil
import time
import pprint
import csv
from collections import Counter
path = r'C:\Heavy Logging Reports\Recorded Issues'
names = os.listdir(path)
folder_name = ['468','478']
for x in folder_name:
fPath = path+x
if not os.path.exists(fPath):
os.makedirs(fPath)
dest1 = 'C:\Heavy Logging Reports\Recorded Issues468'
dest2 = 'C:\Heavy Logging Reports\Recorded Issues478'
for f in names:
if (f[4:].startswith("468WD")):
shutil.copy(os.path.join(path, f), os.path.join(dest1, f))
elif (f[4:].startswith("478WD")):
shutil.copy(os.path.join(path, f), os.path.join(dest2, f))
print('Finished Moving Files!')
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句