Skip to content

Instantly share code, notes, and snippets.

@a-y-khan
Created February 25, 2020 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a-y-khan/d9eacb817c812fcbb201522ec12047b8 to your computer and use it in GitHub Desktop.
Save a-y-khan/d9eacb817c812fcbb201522ec12047b8 to your computer and use it in GitHub Desktop.
import json
def parse_line(file_object):
while True:
line = file_object.readline()
if not line:
break
yield json.loads(line)
with open('test.txt', 'r') as file_reader:
for dict_obj in parse_line(file_reader):
assert isinstance(dict_obj, dict)
print(dict_obj)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment