How to use the pyjstat.pyjstat.Dataset.read function in pyjstat

To help you get started, we’ve selected a few pyjstat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github predicador37 / pyjstat / pyjstat / pyjstat.py View on Github external
def get(self, element):
        """Gets ith element of a collection in an object of the corresponding \
           class.
        Args:
            output(string): can accept 'jsonstat' or 'dataframe_list'

        Returns:
            Serialized JSONstat or a list of Pandas Dataframes,depending on \
            the 'output' parameter.

        """

        if self['link']['item'][element]['class'] == 'dataset':
            return Dataset.read(self['link']['item'][element]['href'])
        elif self['link']['item'][element]['class'] == 'collection':
            return Collection.read(self['link']['item'][element]['href'])
        elif self['link']['item'][element]['class'] == 'dimension':
            return Dimension.read(self['link']['item'][element]['href'])
        else:
            raise ValueError(
                "Class not allowed. Please use dataset, collection or "
                "dimension'")
github predicador37 / pyjstat / examples / example-2.0.py View on Github external
EXAMPLE_URL = 'http://www.cso.ie/StatbankServices/StatbankServices.svc/' \
              'jsonservice/responseinstance/TSM01'

# Elapsed time for pyjstat operations only (without network latency)
start = time.time()

# read dataset from url
dataset_from_json_url = pyjstat.Dataset.read(EXAMPLE_URL)

# write dataframe
dataframe = dataset_from_json_url.write('dataframe')
print(dataframe)

# read dataset from dataframe
dataset_from_dataframe = pyjstat.Dataset.read(dataframe)
print(dataset_from_dataframe)

# write dataset to json-stat string
json_string = dataset_from_dataframe.write()
print(json_string)

# read dataset from json-stat string
dataset_from_json_string = pyjstat.Dataset.read(json_string)
print(dataset_from_json_string)

end = time.time()
print("Time: " + str(end - start))