【发布时间】:2011-09-14 05:00:40
【问题描述】:
我需要帮助找到一个 Python 解决方案来重新格式化包装的行/重写日志文件,这样就没有所描述的换行符。这将使我能够继续寻找不间断的线路。
*.log 中的每个条目都带有时间戳。但是,太长的行会按预期进行换行:换行的部分也带有时间戳。 ">"(大于)是行已换行的唯一指示 - 发生在位置 37。> 日志来自 *nix 机器。
我不知道如何开始......
2011-223-18:31:11.737 VWR:tao abc exec /home/abcd/abcd9.94/bin/set_specb.tcl -s DL 2242.500000 5
2011-223-18:31:11.737 > -20.000000 10
###needs to be rewritten as:
2011-223-18:31:11.737 VWR:tao abc exec /home/abcd/abcd9.94/bin/set_specb.tcl -s DL 2242.500000 5 -20.000000 10
还有一个
2011-223-17:40:07.039 EVT:703 agc_drift_cal.tcl: out of tolerance drift of 5.3080163871 detected! Downlink Alignmen
2011-223-17:40:07.039 >t check required.
###these lines deleted and consolodated as one:
2011-223-17:40:07.039 EVT:703 agc_drift_cal.tcl: out of tolerance drift of 5.3080163871 detected! Downlink Alignment check required.
我不知道如何开始,除了...
for filename in validfilelist:
logfile = open(filename, 'r')
logfile_list = logfile.readlines()
logfile.close
for line in logfile_list:
【问题讨论】:
-
+1 感谢您在第一个问题中发布明确的要求和示例。
-
是否保证“溢出行”在其时间戳之后没有
EVT:XXX或VWR:YYY?>是否保证相对于行首在同一位置? -
是的,我已经扫描了几个日志,似乎 > 保证了新行的开始并且位于相同的位置。它没有 EVT 或前面的其他消息。
标签: python python-2.7 text file-io