@@ -178,7 +178,7 @@ def read_json(*args, chunksize=100000, flatten=False, **kwargs) -> 'StreamingDat
178178 and it must be defined to return an iterator.
179179 If *lines* is True, the function falls back into
180180 :epkg:`pandas:read_json`, otherwise it used
181- @see fn enumerate_json_items. If *lines is ``'stream'``,
181+ @see fn enumerate_json_items. If *lines* is ``'stream'``,
182182 *enumerate_json_items* is called with parameter
183183 ``lines=True``.
184184 Parameter *flatten* uses the trick described at
@@ -212,6 +212,13 @@ def read_json(*args, chunksize=100000, flatten=False, **kwargs) -> 'StreamingDat
212212 it = StreamingDataFrame.read_json(BytesIO(data))
213213 dfs = list(it)
214214 print(dfs)
215+
216+ .. index:: IncompleteJSONError
217+
218+ The parsed json must have an empty line at the end otherwise
219+ the following exception is raised:
220+ `ijson.common.IncompleteJSONError: `
221+ `parse error: unallowed token at this point in JSON text`.
215222 """
216223 if not isinstance (chunksize , int ) or chunksize <= 0 :
217224 raise ValueError ( # pragma: no cover
@@ -228,7 +235,8 @@ def read_json(*args, chunksize=100000, flatten=False, **kwargs) -> 'StreamingDat
228235 del kwargs ['lines' ]
229236
230237 def localf (a0 = args [0 ]):
231- a0 .seek (0 )
238+ if hasattr (a0 , 'seek' ):
239+ a0 .seek (0 )
232240 return enumerate_json_items (
233241 a0 , encoding = kwargs .get ('encoding' , None ), lines = True ,
234242 flatten = flatten )
@@ -280,6 +288,7 @@ def fct2(args=args, chunksize=chunksize, kw=kwargs.copy()):
280288 ** kwargs_create )
281289
282290 def fct3 (st = st , args = args , chunksize = chunksize , kw = kwargs .copy ()):
291+ st .seek (0 )
283292 for r in pandas .read_json (
284293 st , * args , chunksize = chunksize , nrows = chunksize ,
285294 lines = True , ** kw ):
@@ -920,8 +929,9 @@ def __getitem__(self, *args):
920929
921930 def iterate_col ():
922931 "iterate on one column"
932+ one_col = [cols ]
923933 for df in iter_creation ():
924- yield df [[ cols ] ]
934+ yield df [one_col ]
925935 return StreamingSeries (iterate_col , ** self .get_kwargs ())
926936
927937 if not isinstance (cols , list ):
0 commit comments