Sorry - my mistake - try:
infile = open("filex")
match_zips = open("zippys")
result = [line for line in infile if line in match_zips]
print result
When I apply the readlines to the original file, It is taking a lot
longer to process and the outfile still remains blank. Any suggestions?
#!/usr/bin/env python
# Find records that match zipcodes in zips.txt
import os
import sys
def main():
infile = open("/Users/tgw/NM_2010/NM_APR.txt", "r")
outfile = open("zip_match_apr_2010.txt", "w")
zips = open("zips.txt", "r")
match_zips = zips.readlines()
lines = [ line for line in infile if line[149:154] in match_zips ]
outfile.write(''.join(lines))
# print line[149:154]
print lines
infile.close()
outfile.close()
main()
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor