Created
May 20, 2015 09:04
-
-
Save meling/912b2b905ce43fb42f5a to your computer and use it in GitHub Desktop.
Example to extract with reg.exp.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def ExtractPval(line): | |
# 2015-04-09 14:15:37,019 com6 INFO <=3.004882812 [CR][LF] | |
start = line.index('=')+1 | |
stop = line.index('[')-1 | |
return float(line[start:stop]) | |
def main(): | |
f=open('acudump1.txt','r') | |
data = {} | |
line = f.readline() | |
while line != '': | |
match = re.search('<=ips tic 2 acu/(ps.+?) value', line) | |
if match: | |
key = match.group(1) | |
nxtLine = f.readline() | |
value = ExtractPval(nxtLine) | |
if not data.has_key(key): | |
data[key]=[] | |
data[key].append(value) | |
line = f.readline() | |
print data | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment