I have a mydata.txt/.json file containing data like this:
[{"num":1,"name":"Swab Summer: Transformation At the United States Coast Guard Academy","link":"http:\/\/www.amazon.com\/dp\/0982168594\/ref=wl_it_dp_v_nS_ttl\/176-1400914-4673658?_encoding=UTF8&colid=1GM97SGAP8NLI&coliid=I1ELS7DSQ6QV5C","old-price":"N\/A","new-price":"","date-added":"January 10, 2014","priority":"","rating":"N\/A","total-ratings":"","comment":"","picture":"http:\/\/ecx.images-amazon.com\/images\/I\/51MtOOm493L._SL500_SL135_.jpg","page":1}]
[{"num":1,"name":"Vibomex","link":"http:\/\/www.amazon.com\/dp\/B00BR1CUFY\/ref=wl_it_dp_v_S_ttl\/175-5687209-2417046?_encoding=UTF8&colid=C0XVZ38E5WD9&coliid=I1EPDGRY73N5Q2","old-price":"N\/A","new-price":"","date-added":"July 20, 2014","priority":"","rating":"N\/A","total-ratings":"","comment":"","picture":"http:\/\/ecx.images-amazon.com\/images\/I\/31GBqOHskyL._SL500_SL135_.jpg","page":1}]
Basically, multiple json files. These are two separate rows. Now, when I'm trying to import the data in R and making it a dataframe, its only reading the lines corresponding to the first row. Below is my code:
library(rjson)
json_file <- fromJSON(file="mydata.txt")
json_file <- lapply(json_file, function(x) {
x[sapply(x, is.null)] <- NA
unlist(x)
})
do.call("rbind", json_file)
Can anybody help me with reading lines corresponding to each row of mydata.txt/json in a single dataframe in R or python. Any help is appreciated!