我需要從多個report.html grep「狀態」,並製作一個組合的報告,這些報告保存在下面的目錄。用**突出顯示的所有目錄對於每個報告都不相同。我怎麼能做到這一點。 C:\ Program Files(x86)\ Jenkins \ jobs ** E2E_Sanity ** \ jobs ** ABC_E2E_Sanity ** \ builds ** 41 ** \ archive \ performanceTestsReports ** pcRun106821 ** \ Report循環通過多個目錄,並閱讀狀態的HTML文件
-2
A
回答
0
例如,使用蟒蛇和glob模塊:
import glob
files = r"C:\Program Files (x86)\Jenkins\jobs*\jobs*\builds*\archive\performanceTestsReports*\Report"
l = glob.glob(files)
for f in l:
print (f)
0
找到一個小常規程序,可以:
- 提取物修復行號(如果狀態是在固定的行)
搜索一個字 - 狀態並提取信息息
int lineNo = 1 //if the row number is fixed you can extracted by minLine and maxLine int minLine = 1 int maxLine = 20 def line def status def statusRegex def folder = new File("C:\\Users\\user\\Desktop\\ero") folder.eachFile{it-> println "File: ${it.absolutePath}" it.withReader { reader-> while ((line = reader.readLine()) != null & lineNo <= maxLine) { if (lineNo >= minLine) { // println "${lineNo}. ${line}" //if you need specific line numbers } lineNo++ //search for status and print the line status = line.find("status") //search for status by regex and extract all up to < statusRegex = line.find(/(?s)status (.*?)\</) if(status){ println ' full line' + line } if(statusRegex){ println ' by regex' + statusRegex } } } }
相關問題
- 1. PoshRSJob通過文件目錄循環
- 2. Bash腳本通過子目錄循環並寫入文件
- 3. Python搜索多個目錄並閱讀選擇文件
- 4. 通過目錄循環
- 5. 通過目錄循環
- 6. 通過hdfs目錄循環
- 7. 通過多個文件循環VBA
- 8. PowerShell循環通過多個文件
- 9. Python:通過多個csv文件循環並製作多個新的csv文件
- 10. 閱讀文件通過slf4android記錄?
- 11. 通過JSON對象的條目循環並通過反應狀態,得到「狀態未定義」
- 12. 批處理文件循環通過一個目錄?
- 13. 如何通過循環中的Softwareserial庫模仿讀取多個RFID閱讀器?
- 14. 通過html文件循環,獲取文件名並插入每個文件
- 15. 循環通過HTML文件與按鈕
- 16. 現在閱讀netcdf這個日期目錄的多個文件
- 17. jQuery切換/通過3狀態循環
- 18. 循環通過設置狀態
- 19. 在Python 2.7中通過循環目錄加載多個.json文件
- 20. 打開並閱讀不同目錄中的幾個文件
- 21. 閱讀並返回多個Bin文件
- 22. Bash通過目錄中的文件循環
- 23. 循環通過目錄中的蝙蝠,往上用bat文件
- 24. Bash通過目錄和zip中的文件循環
- 25. 閱讀2文件與循環
- 26. bash文件閱讀,while循環
- 27. 通過多個datagridview循環
- 28. Perl中,閱讀目錄,並獲得STAT()對每個文件
- 29. 循環通過多個文件夾來執行命令,然後寫入另一個目錄中的文件
- 30. 使用兩個循環的Java閱讀文本文件
有了一個for循環?你可以給你當前的實施更多的支持? – Adonis
Python Java Groovy ...選擇一個 –