Skip to content

Commit db2749b

Browse files
committed
minor fixups
1 parent c84e515 commit db2749b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

doc/source/io.rst

+1
Original file line numberDiff line numberDiff line change
@@ -2064,6 +2064,7 @@ For line-delimited json files, pandas can also return an iterator which reads in
20642064
df
20652065
df.to_json(orient='records', lines=True)
20662066
2067+
# reader is an iterator that returns `chunksize` lines each iteration
20672068
reader = pd.read_json(StringIO(jsonl), lines=True, chunksize=1)
20682069
reader
20692070
for chunk in reader:

pandas/io/json/json.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ def _get_data_from_filepath(self, filepath_or_buffer):
432432

433433
return data
434434

435-
def combine_lines(self, lines):
435+
def _combine_lines(self, lines):
436436
"""Combines a list of JSON objects into one JSON object"""
437437
lines = filter(None, map(lambda x: x.strip(), lines))
438438
return '[' + ','.join(lines) + ']'
@@ -443,7 +443,7 @@ def read(self):
443443
obj = concat(self)
444444
elif self.lines:
445445
obj = self._get_object_parser(
446-
self.combine_lines(self.data.split('\n'))
446+
self._combine_lines(self.data.split('\n'))
447447
)
448448
else:
449449
obj = self._get_object_parser(self.data)
@@ -486,7 +486,7 @@ def close(self):
486486
def __next__(self):
487487
lines = list(islice(self.data, self.chunksize))
488488
if lines:
489-
lines_json = self.combine_lines(lines)
489+
lines_json = self._combine_lines(lines)
490490
obj = self._get_object_parser(lines_json)
491491

492492
# Make sure that the returned objects have the right index.

0 commit comments

Comments
 (0)