Skip to content

Instantly share code, notes, and snippets.

@noahgift
Created February 28, 2018 23:02
Show Gist options
  • Save noahgift/e0a8e86b61ad013f29a2f575c7e9bf14 to your computer and use it in GitHub Desktop.
Save noahgift/e0a8e86b61ad013f29a2f575c7e9bf14 to your computer and use it in GitHub Desktop.
#Parse a log and yield ONLY one line
def parse_log(path):
with open("logfile.txt") as myfile:
res = myfile.readlines()
for line in res:
yield line
#generator pipeline
stream = parse_log("logfile.txt") # step 1
split_it = (line.split() for line in stream) #step 2
#step 3
###To Test
### In [16]: stream = parse_log("logfile.txt")
### split_it = (line.split() for line in stream)
### next(split_it)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment