Skip to content
Snippets Groups Projects
Commit a936a822 authored by Alice Brenon's avatar Alice Brenon
Browse files

Add write capacities to the JSONL module

parent 7799b94c
No related branches found
No related tags found
No related merge requests found
import json
def load(file_path):
with open(file_path, 'r') as input_file:
for line in input_file.readlines():
if type(file_path) == str:
with open(file_path, 'r') as input_file:
for line in input_file.readlines():
yield json.loads(line)
else:
for line in file_path.readlines():
yield json.loads(line)
def save(file_path, objects):
if type(file_path) == str:
with open(file_path, 'w') as output_file:
saveObjects(output_file, objects)
else:
saveObjects(file_path, objects)
def saveObjects(output_file, objects):
for obj in objects:
json.dump(obj, output_file)
print(file=output_file)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment