Please use Reply All whern responding to the list.

 

> lines = [line for line in infile if line[149:154] not in match_zips]
>
>Nope. I tried that. I actually modified your comprehension 
>that you provided about a month ago. 
>Works great for NOT matching, but can't figure out how to match. 
>Do you have another suggestion?def main():
>
>     infile = open("/Users/tgw/NM_2010/NM_APR.txt", "r")
>     outfile = open("zip_match_apr_2010.txt", "w")
>     match_zips = open("zips.txt", "r")
>
>You probably are best to read the zips file into a list, 
>stripping the newlines: 
>
>
>matchzips = [match.strip() for match in open('zips.txt')]
>
>then
>
>     lines = [line for line in infile if line[149:154] in match_zips] 
>Should work...
Either that or add a newline to the end of the slice.

HTH,

Alan G.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to