Re: How to query the dataset and easily cycle through the results?

17 views
Skip to first unread message

Xavier Badosa

unread,
Nov 27, 2017, 7:59:24 AM11/27/17
to json...@googlegroups.com
Is there something like : JSONstat( j ).Dataset0 ).Data( { "time" : "2014" } ).values

In the case of the OECD sample file, yes because it has three dimensions and one is contant (check the "status" parameter of Data():


). Which means that you can actually do: .Data( { "year" : "2003" }, false )

You can try it by visiting


and opening the browser console.

If you type

JSONstat("https://json-stat.org/samples/oecd.json").Dimension("year").length

you'll get 12 (oecd.json has a time dimension called "year" with 12 categories).

The dataset has 432 data:


Typing

JSONstat("https://json-stat.org/samples/oecd.json").Data( { "year" : "2003" }, false )

you'll get the 36 values (432/12=36) you are looking for.

This works because oecd.json has three dimensions and one is contant ([1, 36, 12]):


When you freeze the "year" dimension ("2003"), there's only one non-constant dimension (area, with 36 categories).

In general, to get a particular slice of a dataset you should use the Slice() method:
X.

On Fri, Nov 24, 2017 at 3:02 PM, <marco.ve...@accurat.it> wrote:
Hi I'm new to json-stat but I've the following problem: I want to get values of a specific subset of values depending on a selected dimension.
For example: using the following: http://json-stat.org/samples/oecd.json  I want to get all the values related to the year 2003, independently from the other dimensions.
How can I achieve that? Need I to cycle through all the values of each "unspecified" dimension using the .Data({all_dimensions}) or there is a simpler way?

Is there something like : JSONstat( j ).Dataset( 0 ).Data( { "time" : "2014" } ).values
That return all the values that are related to the specific time?


Thanks

--
You received this message because you are subscribed to the Google Groups "json-stat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to json-stat+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages