rjsonio

Extracting JSON data from Google geocoding API in R

早过忘川 提交于 2020-01-07 04:04:07
问题 I'm quite new to Json data structure and so unable to extract data from it. This is the sample rows from Json data which is stored in csv file row1) {"results":[{"address_components":[{"long_name":"16","short_name":"16","types":["street_number"]},{"long_name":"Bhagwan Tatyasaheb Kawade Road","short_name":"BT Kawde Road","types":["route"]},{"long_name":"Palmgrove Society","short_name":"Palmgrove Society","types":["neighborhood","political"]},{"long_name":"Uday Baug","short_name":"Uday Baug",

Parsing text file of one line JSON objects using RJSONIO

自闭症网瘾萝莉.ら 提交于 2020-01-06 02:22:07
问题 What I want: I would like to parse a text file of the form {"business_id": "rncjoVoEFUJGCUoC1JgnUA", "full_address": "8466 W Peoria Ave\nSte 6\nPeoria, AZ 85345", "open": true, "categories": ["Accountants", "Professional Services", "Tax Services", "Financial Services"], "city": "Peoria", "review_count": 3, "name": "Peoria Income Tax Service", "neighborhoods": [], "longitude": -112.241596, "state": "AZ", "stars": 5.0, "latitude": 33.581867000000003, "type": "business"} {"business_id":

Accessing only second sub-element from json object in r

巧了我就是萌 提交于 2019-12-25 08:48:27
问题 This is a sample rows from json object. row1) {"results":[{"address_components":[{"long_name":"16","short_name":"16","types":["street_number"]},{"long_name":"Bhagwan Tatyasaheb Kawade Road","short_name":"BT Kawde Road","types":["route"]},{"long_name":"Palmgrove Society","short_name":"Palmgrove Society","types":["neighborhood","political"]},{"long_name":"Uday Baug","short_name":"Uday Baug","types":["political","sublocality","sublocality_level_2"]},{"long_name":"Ghorpadi","short_name":"Ghorpadi

Struggling to import NZ companies extract into R (json)

左心房为你撑大大i 提交于 2019-12-25 01:09:21
问题 The NZ companies register offers a json file containing all publicly available business info. This file comes in at a whopping 40gb, but there is also a smaller json file (~250mb) containing data on unincorporated entities (sole traders etc). As a warm up excercise I thought i'd have a go importing it into R to get an idea of size, scalability and computational reqs. I'm having alot of trouble importing the smaller json file into R. I've tried jsonlite, RJSONIO, rjson but it appears that the

Ability to JSON serialize and deserialize int64 with precision in R

╄→гoц情女王★ 提交于 2019-12-24 14:12:45
问题 In R, Int64 whole numbers can not be accurately serialized to and from JSON, because existing JSON libraries will coerce the value into a numeric, or expect to represent the number in scientific notation. Does anyone know of a way to accurately serialize and deserialize whole Int64 numbers to/from JSON with precision, or is a library modification (probably to RJSONIO) required? The full story, including libraries I have tried so far, and the gacky workarounds necessary for the interim: >

R: Handling error response in JSON format

假装没事ソ 提交于 2019-12-24 12:33:07
问题 I am requesting user details to the Facebook Graph API, such as require(RJSONIO) response <- RJSONIO::fromJSON("http://graph.facebook.com/?ids=Jack") print(response) # $Jack # id first_name gender last_name locale # "534213341" "Jack" "male" "Lindamood" "en_US" # name username # "Jack Lindamood" All good. But then sometime I have an error from the API to handle. Such as this error response (hope nobody will take this username...) { "error": { "message": "(#803) Some of the aliases you

R error - subscript out of bounds

三世轮回 提交于 2019-12-24 11:45:07
问题 I am trying to run this code which takes a list of addresses and runs each one through Google's Geocode API (using function Addr2latlng below) to get the latitude/longitude and puts each one into a data frame using ProcessAddrList below. The problem is Addr2latlng works fine for one address and ProcessAddrList works fine for up to 10 addresses, but from 11 addresses or more I get the error below. For 10 addresses this works fine. To run the code below requires the packages RCurl and RJSONIO

How to correctly deal with escaped Unicode Characters in R's library RJSONIO when reading json from a file

一曲冷凌霜 提交于 2019-12-24 04:41:08
问题 I am using R's RJSONIO to read json from a file. The json contains unicode characters, which get read incorrectly. The code works when the json is passed as string as shown by the author of the R package in the question on stackoverflow How to correctly deal with escaped Unicode Characters in R e.g. the em dash (—). However when the json is read from a file, it does not produce the correct unicode representation. As seen below: fromJSON(content="~/MTS/temp") $query $query$categorymembers

RJSONIO vs rjson - better tuning

◇◆丶佛笑我妖孽 提交于 2019-12-21 07:16:10
问题 UPDATE: The tl;dr is that RJSONIO is no longer the faster of the two options. Rather rjson is now much faster. See the comments for additional confirmation of results I was under the impression that RJSONIO was supposed to be faster tha rjson . However, I am getting the opposite results. My Question is: Is there any tuning that can/should be performed to improve the results from RJSONIO ? (ie, Am I overlooking something?) Below are the comparisons using real data (where U is the contents of a

Handling NaN when using fromJSON in R

瘦欲@ 提交于 2019-12-13 14:13:56
问题 I'm trying to use the fromJSON function in R to read in a JSON file that was given to me, however this file has NaN in it and I can't read it in properly. This is the error I get: Error in feed_push_parser(buf) : lexical error: invalid char in json text. Anyone know how to read NaN values when reading in a json file into R? 回答1: I had similar problem. To resolve this, you can try one of the below as it worked for me. i) Open JSON file in np++ and replace any value with NaN with "NA" (quoted).