Created
November 22, 2011 21:57
-
-
Save tkh44/1387146 to your computer and use it in GitHub Desktop.
Surgery Benefit Formatter
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 fileinput | |
import sys | |
import re | |
filename = sys.argv[1] | |
def benefitFormat(matchobj): | |
print matchobj.group(0) | |
return '[benefit name=\"' + matchobj.group(0).rstrip() + '\"' | |
with open(filename) as infile: | |
with open(filename.replace('.txt', '')+"_formatted.txt", "w") as outfile: | |
for i, line in enumerate(infile): | |
print "Line %s: " % i | |
#print line | |
outfile.writelines(re.sub('([A-Za-z]+[A-Za-z/,\s18]+\s)+', benefitFormat, line, count=1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment