[ create a new paste ] login | about

Link: http://codepad.org/IcVhsx1J    [ raw code | fork ]

Python, pasted on Jun 17:
#! /usr/bin/python

import re
import sys
import time

#borrowed from http://www.peterbe.com/plog/uniqifiers-benchmark
def f5(seq, idfun=None):
    # order preserving
    if idfun is None:
        def idfun(x): return x
    seen = {}
    result = []
    for item in seq:
        marker = idfun(item)
        if marker in seen: continue
        seen[marker] = 1
        result.append(item)
    return result

file1 = r"/home/rutschman/python/extract_input"
rawstr = r"""(?P<date>\w{3,5}\s\d{2}?)\s(?P<rest>.*?$)"""
# Open The File

InputFile = open(file1, "r")
OutputFile = open("extract_output.txt","w")

OutputFile.write(time.asctime()+"\n")

# Create List based on DATE
list = []

rxinput = re.compile(rawstr)
list = []
for line in InputFile:
        for date in rxinput.finditer(line):
                list.append(date.group(1))

list=f5(list)
for i in list:
        print i
        for rest in rxinput.finditer(line):
                if list == (rest.group(1)):
                        print "\t"+(rest.group(2))
                        continue

print ""

InputFile.close()
OutputFile.close()


Create a new paste based on this one


Comments: