MCPcopy Create free account
hub / github.com/EntilZha/PyFunctional / jsonl

Method jsonl

functional/streams.py:192–210  ·  view source on GitHub ↗

Reads and parses the input of a jsonl file stream or file. Jsonl formatted files must have a single valid json value on each line which is parsed by the python json module. >>> seq.jsonl('examples/chat_logs.jsonl').first() {u'date': u'10/09', u'message': u'

(self, jsonl_file)

Source from the content-addressed store, hash-verified

190 return self(csv_input).cache(delete_lineage=True)
191
192 def jsonl(self, jsonl_file):
193 """
194 Reads and parses the input of a jsonl file stream or file.
195
196 Jsonl formatted files must have a single valid json value on each line which is parsed by
197 the python json module.
198
199 >>> seq.jsonl('examples/chat_logs.jsonl').first()
200 {u'date': u'10/09', u'message': u'hello anyone there?', u'user': u'bob'}
201
202 :param jsonl_file: path or file containing jsonl content
203 :return: Sequence wrapping jsonl file
204 """
205 if isinstance(jsonl_file, str):
206 file_open = get_read_function(jsonl_file, self.disable_compression)
207 input_file = file_open(jsonl_file)
208 else:
209 input_file = jsonl_file
210 return self(input_file).map(jsonapi.loads).cache(delete_lineage=True)
211
212 def json(self, json_file):
213 """

Callers 6

test_jsonlMethod · 0.80
test_gzip_jsonlMethod · 0.80
test_bz2_jsonlMethod · 0.80
test_xz_jsonlMethod · 0.80
test_to_jsonlMethod · 0.80

Calls 3

get_read_functionFunction · 0.90
cacheMethod · 0.80
mapMethod · 0.80

Tested by 6

test_jsonlMethod · 0.64
test_gzip_jsonlMethod · 0.64
test_bz2_jsonlMethod · 0.64
test_xz_jsonlMethod · 0.64
test_to_jsonlMethod · 0.64