【发布时间】:2018-02-08 12:43:30
【问题描述】:
location severity group timestamp description
'0/PM0 major environ 02/07/18 22:50:55 Power Module Output Disabled'
'0/FT1 critical environ 02/07/18 22:50:55 Fan tray is removed from chassis.'
从上面的输出中,我必须得到具有 location 作为键和 severity 、 group 、 timestamp 和 description 作为值的字典。
我无法获取timestamp 和description,请参阅输出:
{'0/PM0': ['major', 'environ', '22:50:55', 'Power'], '0/FT1': ['critical', 'environ', '22:50:55', 'Fan']}
预期输出:
{'0/PM0': ['major', 'environ', '02/07/18 22:50:55', 'Power Module Output Disabled'], '0/FT1': ['critical', 'environ', '02/07/18 22:50:55', 'Fan tray is removed from chassis']
【问题讨论】:
-
使用正则表达式
re.split("\s\s+",line) -
您要求我们想象您编写的代码,然后告诉您问题出在哪里。您是使用
pandas或csv还是手动拆分输入?
标签: python