NYCPlanning / db-factfinder

data ETL for population fact finder (decennial + acs)
https://nycplanning.github.io/db-factfinder/factfinder/
MIT License
2 stars 3 forks source link

Version metadata.json #62

Closed SPTKL closed 3 years ago

SPTKL commented 3 years ago

To initialize class:

pff = Pff(
    api_key='XXXXXXXXXXXXXXXXX', 
    year = 2018,
    source = 'acs'
)
SPTKL commented 3 years ago

convert them into computed properties

        with open(f"{Path(__file__).parent}/data/metadata.json") as f:
            self.metadata = json.load(f)
        with open(f"{Path(__file__).parent}/data/median.json") as f:
            self.median = json.load(f)
        with open(f"{Path(__file__).parent}/data/special.json") as f:
            self.special = json.load(f)

to

    @cached_property
    def metadata(self) -> list:
           with open(f"{Path(__file__).parent}/data/{source}/{year}/metadata.json") as f:
               return json.load(f)
SPTKL commented 3 years ago

65 #64