Created
May 23, 2012 22:00
-
-
Save binarymatt/2778104 to your computer and use it in GitHub Desktop.
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 sys | |
def bad_line(line, index): | |
if line[index] != 'U': | |
return True | |
def process_file(f, index): | |
index = int(index) | |
bad_records = [] | |
for i,line in enumerate(f): | |
if line.strip(): | |
if bad_line(line, index): | |
bad_records.append((i,line)) | |
return bad_records | |
def main(): | |
filename = sys.argv[1] | |
index = sys.argv[2] | |
f = open(filename) | |
bad = process_file(f, index) | |
print "BAD RECORDS" | |
print ','.join([str(line[0]) for line in bad]) | |
if __name__=="__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment