Пример #1
0
    def get_data(self, **kwargs):

        states = kwargs.get('states')
        years = kwargs.get('years')
        #json_path = kwargs.get('json_path',None)

        #Removing Duplicates
        states = list(set(states))
        years = list(set(years))

        #Checking Errors
        self.check_state_years_inputs_errors(states, years)

        #Downloading Data
        #json_result = self.io_utils.read_json(json_path) if json_path else {'metadata': {'column_descriptions':{}}}
        for state in states:
            for year in years:
                dir_path = os.path.join(self.sinasc_raw_dir, state)
                year_str = str(year)
                if not os.path.exists(dir_path):
                    self.io_utils.create_folder_structure(folder=dir_path)
                if not os.path.exists(
                        os.path.join(dir_path, f'{state}_{year_str}.csv.gz')):
                    df = download(state, year)
                    self.io_utils.save_df_zipped_csv(
                        df=df,
                        dirpath=dir_path,
                        file_name=f'{state}_{year_str}')
Пример #2
0
 def test_download_new(self):
     df = download('SE', 2015)
     self.assertIn('IDADEMAE', df.columns)
     self.assertGreater(len(df), 0)
Пример #3
0
 def test_download_old(self):
     df = download('AL', 1994)
     self.assertIn('IDADE_MAE', df.columns)
     self.assertGreater(len(df), 0)
Пример #4
0
 def test_download_new(self):
     df = download('SE', 2015)
     self.assertIn('IDADEMAE', df.columns)
     self.assertGreater(len(df), 0)
Пример #5
0
 def test_download_old(self):
     df = download('AL', 1994)
     self.assertIn('IDADE_MAE', df.columns)
     self.assertGreater(len(df), 0)
Пример #6
0
 def test_download_new(self):
     df = download("SE", 2015)
     self.assertIn("IDADEMAE", df.columns)
     self.assertGreater(len(df), 0)
Пример #7
0
 def test_download_old(self):
     df = download("AL", 1994)
     self.assertIn("IDADE_MAE", df.columns)
     self.assertGreater(len(df), 0)