Ported-> Sick of doing research manually?


55 views

This post was originally from October 10, 2007…

I was too. It really annoys me to have to search through text for relevant facts, so I wrote this small script to parse text quickly looking for keywords and save the resultant facts to a second text file. Quite simple, but perhaps useful. You’ll need Python (www.python.org) to run it.

#Scoper v1.0 by Raven (EyesOfARaven), October 10, 2007
import sys
f=file(raw_input(”File->”))
kw=raw_input(”Keyword->”).lower()
of=file(raw_input(”Outfile->”),”w”)
count=0
linecount=0
for line in f.readlines():
linecount+=1
print “Parsing line “+str(linecount)
if not ((line.lower()).find(kw)==-1):
of.write(line+”\r\n”)
count+=1
print “Found on “+str(linecount)+”, “+str(count)+” total.”
else:
print “Not found on line “+str(linecount)
else:
print “Parsing Completed, “+str(count)+” of “+str(linecount)+” lines contained “+’”‘+kw+’”.’
sys.exit(1)

Popularity: 2% [?]

Explore posts in the same categories: python

Comment: