import sys
import re
import numpy

def match_and_get(pattern):
    p = pattern.split(',')
    text = p[0]
    skip, lines, start, end = map(int, p[1:])
    def match(line):
        return re.search(text, line)
    match.skip = skip
    match.lines = lines
    def get(line):
        #print "get:",line.split()
        fields = [ float(i) for i in line.split()[start-1: end] ]
        #print fields
        return fields
    return (text, match, get, [])
        
rules=[]

for p in open('patterns').readlines():
    #print p.split()
    rules.append(match_and_get(p))
        
with open(sys.argv[1]) as target:
    for line in target:
        for t, m, g, r in rules:
            if m(line):
                for s in range(m.skip): line=next(target)
                for l in range(m.lines): line+=next(target)
                r.append(g(line))

from util import full
for t,m,g,r in rules:
    print t, full.init(r).T
    

@@ -484,18 +484,19 @@
 pen(
-'patterns'
+sys.argv%5B1%5D
 ).re
@@ -590,17 +590,17 @@
 ys.argv%5B
-1
+2
 %5D) as ta

Update match_get with sys.argv