我正在尝试从多个文本(nmap)文档中收集特定行,然后以表格格式创建一个新文件。我还没有进入表格部分,因为我无法让附加工作。
#imports
import os
#Change directories
os.chdir ("M:\\Daily Testing")
#User Input
print "What is the name of the system being scanned?"
sys = raw_input("> ")
#Subfolder selected
os.chdir (sys)
os.chdir ("RESULTS")
#variables
tag = ["/tcp", "/udp"]
fout = [sys + " Weekly Summary.csv"]
import glob
for filename in glob.glob("*.nmap"):
with open(filename, "rU") as f:
for line in f:
if not line.strip():
continue
for t in tag:
if t in line:
fout.write(line)
else:
continue