[R] JSONlite import problem

K. Elo maillists at nic.fi
Sun Oct 25 17:05:30 CET 2015


Hi,

thanks to Duncan and Jeroen to quick replies. I was actually my thinking 
error :) I suppoed 'fromJSON' to cope with a multi-line file or a list, 
but this seems not to be the case. So I first read the file with 
'readLines' into a list and processed all items with 'fromJSON' within a 
for-loop. This worked.

Best,
Kimmo

25.10.2015, 01:27, Jeroen Ooms wrote:
> On Sat, Oct 24, 2015 at 1:35 PM, Duncan Murdoch
> <murdoch.duncan at gmail.com> wrote:
>>
>>> However, editing the file with a text editor to create "proper" EOF
>>> doesn't help.
>>
>> The problem is that you have valid-looking JSON objects on each odd
>> numbered line, separated by single blank lines.  The parser expects an
>> EOF at the end of the first object, but instead it found a blank line
>> and another object.
>
>
> Actually this is a common json streaming format called ndjson a.k.a.
> jsonlines. Usually you can stream-import the data directly in jsonlite
> using the stream_in function. See ?stream_in for examples.
>
> However in this case there are white lines in between the json lines
> which makes it a bit more tricky. I will add a feature to skip over
> those lines.
>



More information about the R-help mailing list