load_jsonl love jsonl
# https://medium.com/@galea/how-to-love-jsonl-using-json-line-format-in-your-workflow-b6884f65175b
import json
def dump_jsonl(data, output_path, append=False):
"""
Write list of objects to a JSON lines file.
"""
mode = 'a+' if append else 'w'
with open(output_path, mode, encoding='utf-8') as f:
for line in data:
json_record = json.dumps(line, ensure_ascii=False)
f.write(json_record + '\n')
print('Wrote {} records to {}'.format(len(data), output_path))
def load_jsonl(input_path) -> list:
"""
Read list of objects from a JSON lines file.
"""
data = []
with open(input_path, 'r', encoding='utf-8') as f:
for line in f:
data.append(json.loads(line.rstrip('\n|\r')))
print('Loaded {} records from {}'.format(len(data), input_path))
return data
Also in JavaScript:
- chartjs bar data on top
- How do I redirect to another webpage
- javascript prevent context menu
- formatDoubl js
- rock paper scissors javascript
- javascript add commas to number
- json schema validator allows null
- get channel id discord js v12
- how to version a react app azure pipelines
- cognito listUser using amazon-cognito-identity-js
- how to create angular project in visual studio code windows 10
- compare two arrays javascript
- what called window.onerror
- javascript date now
- fetch is not defined amazon-cognito-identity-js
- js html
- substring javascript
- how to get a bot online on discord
- javascript get number of elements in object
- make internal value in render function in react native
- jquery selected option text
- remove character at index
- react js materilize
- get object name javascript