ryelprjson

Can anyone help me on extracting data using Json file of Yelp to the R?


  1. https://www.yelp.com/dataset/documentation/main

There are some examples for the Python. But none using the rjson package.

I'm Confused and have no idea on how to establish a connection and get the data in the form of csv.

I really appreciate if any expert can help me on this.


Solution

  • Upon searching the YELP dataset, it can only be accessed offline so the first step is to download the dataset in this link since I had trouble accessing the one on the yelp dataset.

    https://www.kaggle.com/datasets/yelp-dataset/yelp-dataset?resource=download

    After downloading it, you need to unzip it to access the json files and you can then open it up in R using jsonlite.

    library(jsonlite)
    
    #the path of the json file you want to access in your local computer
    file <- "yelp_academic_dataset_business.json"
    
    business <- jsonlite::stream_in(textConnection(readLines(file, n=300000)), flatten = TRUE)
    
    glimpse(business)
    

    More information can be seen here: https://rpubs.com/kgwebu/832640