12345678910111213141516171819202122232425262728 |
- #!/usr/bin/env python
- import jsonlines
- from pprint import pprint
- filename = 'test.json'
- def make_glob():
- d = dict()
- for x in range(10):
- key = "important{0}".format(x)
- d[key] = "Yeah, {0} is very important to remember.".format(x)
- return d
- print("Creating...")
- with jsonlines.open (filename, 'w') as writer:
- for x in range(200):
- writer.write(make_glob())
- print("Reading...")
- with jsonlines.open(filename, 'r') as reader:
- for obj in reader:
- pprint(obj)
-
|