Skip to content

Instantly share code, notes, and snippets.

@binarymatt
Created May 23, 2012 22:00
Show Gist options
  • Save binarymatt/2778104 to your computer and use it in GitHub Desktop.
Save binarymatt/2778104 to your computer and use it in GitHub Desktop.
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