Last active
January 19, 2016 02:07
-
-
Save Ja1meMartin/db1b71ed90921aff24fa to your computer and use it in GitHub Desktop.
This file contains 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
#Context Managers autoclose file | |
with open(sourcefile,'r') as infile, open(targetfile,'w') as outfile: | |
# split on your search string | |
# if not found list of length 1 | |
# if found list with two strings either size | |
line_iterator = (str(line).split("recap?id=") for line in infile) # generator lazy evaluation | |
# take the second item in the list | |
# ignore the first len(search_str) characters | |
ids = len ( line[1][searchlen:] for line in line_iterator if len(line) > 1) | |
for id in ids: | |
outfile.write(game_id) | |
outfile.write("\n") | |
print ( str( len( ids ) + " : records written") | |
print ("Parse end") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment