Skip to content

Instantly share code, notes, and snippets.

@LouisdeBruijn
Created December 31, 2020 11:31
Show Gist options
  • Select an option

  • Save LouisdeBruijn/f2c13c03633d226448535228fa27cceb to your computer and use it in GitHub Desktop.

Select an option

Save LouisdeBruijn/f2c13c03633d226448535228fa27cceb to your computer and use it in GitHub Desktop.
import jsonlines
def write_jsonl(json_data, file_loc=False):
"""Write list object to newline-delimited JSON format.
:param json_data: data in an object that is to be converted to JSONL format
:type json_data: list
:param file_loc: location of file to write to
:type file_loc: str, bool
"""
with jsonlines.open(file_loc, 'w') as writer:
writer.write_all(json_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment