コード例 #1
0
    def _fetch_dimensions(self, dataset):
        yield Dimension("date")

        # Assign a label to one of the allowed values
        mun = Dimension("municipality",
                        allowed_values=["Umeå kommun", "Robertsfors kommun"])
        mun.allowed_values["Robertsfors kommun"].label = "Robertsfors kommun"
        yield mun

        yield Dimension("gender")
コード例 #2
0
    def _fetch_dimensions(self, dataset):
        """ Declaring available dimensions like this is not mandatory,
         but nice, especially if they differ from dataset to dataset.

         If you are using a built in datatype, you can specify the dialect
         you are expecting, to have values normalized. This scraper will
         look for Swedish month names (e.g. 'Januari'), but return them
         according to the Statscraper standard ('january').
        """
        yield Dimension(u"date", label="Day of the month")
        yield Dimension(u"month", datatype="month", dialect="swedish")
        yield Dimension(u"year", datatype="year")
コード例 #3
0
 def _fetch_dimensions(self, dataset):
     """ Iterate through semesters, counties and municipalities.
     """
     yield Dimension(u"school")
     yield Dimension(u"year",
                     datatype="year")
     yield Dimension(u"semester",
                     datatype="academic_term",
                     dialect="swedish")  # HT/VT
     yield Dimension(u"municipality",
                     datatype="year",
                     domain="sweden/municipalities")
コード例 #4
0
    def _fetch_dimensions(self, dataset):
        """ Declaring available dimensions like this is not mandatory,
         but nice, especially if they differ from dataset to dataset.

         If you are using a built in datatype, you can specify the dialect
         you are expecting, to have values normalized. This scraper will
         look for Swedish month names (e.g. 'Januari'), but return them
         according to the Statscraper standard ('january').
        """
        yield Dimension(u"region",
                        label="municipality or county",
                        datatype="region",
                        dialect="arbetsmiljoverket")
        yield Dimension(u"period", label="Year or month")
コード例 #5
0
ファイル: SMHIScraper.py プロジェクト: jplusplus/statscraper
    def _fetch_dimensions(self, parameter):
        yield (StationDimension("station"))
        # Hack: This redundant of the station dimension, but
        # necessary to be able to include both station name
        # (=readabilty) and key in resultset.
        # It would be better if the ResultSet object could
        # handle both label and key print.
        yield (Dimension("station_key"))
        yield (Dimension("period", allowed_values=PERIODS))
        yield (Dimension("parameter"))

        example_data = parameter._get_example_csv()
        for dim in example_data.columns:
            yield (Dimension(dim))
コード例 #6
0
 def test_translations(self):
     """Test standalone translation."""
     municipalities = Dimension("municipality",
                                datatype="region",
                                domain="sweden/municipalities")
     municipality = DimensionValue("Stockholms kommun", municipalities)
     assert municipality.translate("numerical") == "180"
コード例 #7
0
    def _fetch_dimensions(self, dataset):
        data = requests.get(self._api_path(dataset)).json()
        try:
            for d in data["variables"]:
                yield Dimension(d["code"],
                                label=d["text"],
                                allowed_values=d["values"])

        except KeyError:
            yield None
コード例 #8
0
 def _fetch_dimensions(self, dataset):
     """Yield the available dimensions in <dataset>."""
     yield Dimension('municipality_groups', label='municipality groups')
     yield Dimension('municipality', label='municipality')
     yield Dimension('kpi', label='indicator')
     yield Dimension('kpi_label', label='indicator name')
     yield Dimension('gender', label='gender')
     yield Dimension('period', label='period')
     yield Dimension('status', label='status')
コード例 #9
0
 def _fetch_dimensions(self, dataset):
     yield Dimension("niva")  # skola|kommun|län
     yield Dimension("kommunkod")
     yield Dimension("kommun_namn")
     yield Dimension("lan_kod")
     yield Dimension("lan_namn")
     yield Dimension("huvudman")
     yield Dimension("huvudman_name")
     yield Dimension("skolnamn")
     yield Dimension("skol_kod")
     yield Dimension("amne")
     yield Dimension("period")
     yield Dimension("periodicity")
     yield Dimension("uttag")
     yield Dimension("variable")
     yield Dimension("status")
コード例 #10
0
 def _fetch_dimensions(self, dataset):
     yield Dimension('year', datatype='year')
     yield Dimension('month')  # TODO: Convert to datatype month
     yield Dimension('vehicle_type')
     yield Dimension('status')
コード例 #11
0
 def _fetch_dimensions(self, dataset):
     yield Dimension(u"municipality", datatype="region")
コード例 #12
0
 def _fetch_dimensions(self, dataset):
     yield Dimension("region")
     yield Dimension("year")
     yield Dimension("month")
     yield Dimension("viltslag")
コード例 #13
0
ファイル: scraper.py プロジェクト: jplusplus/uc_scraper
 def _fetch_dimensions(self, dataset):
     yield Dimension("month")  # query month 2016-01
     yield Dimension("column")  #
     yield Dimension("group")  # "Stockholms län"
     yield Dimension("grouper")  # "Län"