FailedMathematician FailedMathematician - 1 year ago 239
JSON Question

R json,incomplete final line found

My problem: R json,incomplete final line found

My effort: I followed 'Incomplete final line' warning when trying to read a .csv file into R

I used this site to check my files validity. It is data from my facebook news feed collected using graph api.

My code:

json_data <- fromJSON(paste(readLines(paste0(work,"SunwayFB.txt")), collapse=""))

My error:

Warning message:
In readLines(paste0(work, "SunwayFB.txt")) :
incomplete final line found on 'C:/ContainingFolder/SunwayFB.txt'

Answer Source

It works without any errors if you read the file with fromJSON instead of readLines.

fp <- file.path(work, "SunwayFB.txt")
json_data <- fromJSON(file = fp)

By the way: For the readLines way, you have to add a new line at the end of the file.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download