Source code for pytablewriter.writer.text._jsonlines

# encoding: utf-8

from __future__ import absolute_import, unicode_literals

from ._json import JsonTableWriter

    import simplejson as json
except ImportError:
    import json

[docs]class JsonLinesTableWriter(JsonTableWriter): """ A table writer class for JSON lines format. :Example: :ref:`example-jsonl-writer` """ FORMAT_NAME = "json_lines" @property def format_name(self): return self.FORMAT_NAME @property def support_split_write(self): return True
[docs] def write_table(self): """ |write_table| with `Line-delimited JSON(LDJSON) <>`__ /NDJSON/JSON Lines format. :raises pytablewriter.EmptyHeaderError: If the |headers| is empty. :Example: :ref:`example-jsonl-writer` """ with self._logger: self._verify_property() self._preprocess() for values in self._table_value_matrix: self._write_line(json.dumps(values))