Chicago/RSocrata

Receiving an empty dataframe

will-champ opened this issue · 3 comments

Hello! I am trying to pull data from NY State regarding vehicle registration (see here) filtering for New York City, which appears as NEW YORK in the table. Code is as follows:

mydata <- RSocrata::read.socrata("https://data.ny.gov/resource/w4pv-hbkt.json?$where=city='NEW YORK'")

Every time I enter it, the code executes but I receive a dataframe with 0 observations. Any ideas of why this may be?

@willchampbrown - I attempted to replicate the query https://data.ny.gov/resource/w4pv-hbkt.json?$where=city='NEW YORK' in the browser, but returned an empty frame. It seems like the query itself doesn't return results so nothing is being returned to RSocrata.

@willchampbrown - I took a look at the query, which seems fine. I then tried to perform a similar filter on the data in the browser, but it seems like "NEW YORK" is not a valid string. I looked at the entire JSON and appears there are tons of spaces in a given response.

Here is an entry for one in New York:

{"record_type":"VEH ",
"vin":"9309800080       ",
"registration_class":"PAS",
"city":"NEW YORK       ",
"state":"NY",
"zip":"10017",
"county":"NEW YORK    ",
"model_year":"1979",
"make":"PORSC",
"body_type":"2DSD",
"fuel_type":"GAS     ",
"unladen_weight":"2855",
"reg_valid_date":"2018-08-01T00:00:00.000",
"reg_expiration_date":"2020-09-02T00:00:00.000",
"color":"BL   ",
"scofflaw_indicator":"N",
"suspension_indicator":"N",
"revocation_indicator":"N"}

So, I just think the query needs to reflect the spaces. Also note, sometimes NYC is specified as "New York" and other times as "New York City".

entire JSON

Thank you so much – you are absolutely right, I was just copying the value from the table. I will be looking at the json moving forward to validate.