How to use the jsonlines.jsonlines.Writer function in jsonlines

To help you get started, we’ve selected a few jsonlines examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wbolster / jsonlines / jsonlines / jsonlines.py View on Github external
with jsonlines.open('out.jsonl', mode='w') as writer:
            writer.write(...)

    :param file-like fp: name of the file to open
    :param str mode: whether to open the file for reading (``r``),
        writing (``w``) or appending (``a``).
    :param **kwargs: additional arguments, forwarded to the reader or writer
    """
    if mode not in {'r', 'w', 'a'}:
        raise ValueError("'mode' must be either 'r', 'w', or 'a'")
    fp = io.open(name, mode=mode + 't', encoding='utf-8')
    if mode == 'r':
        instance = Reader(fp, **kwargs)
    else:
        instance = Writer(fp, **kwargs)
    instance._should_close_fp = True
    return instance

jsonlines

Library with helpers for the jsonlines file format

BSD-2-Clause
Latest version published 1 year ago

Package Health Score

68 / 100
Full package analysis

Similar packages