[docs]classMaldives(CountryTestBase):location:str="Maldives"units:str="samples tested"source_label:str="Maldives Health Protection Agency"source_url:str="https://covid19.health.gov.mv/v2_data.json"source_url_ref:str="https://covid19.health.gov.mv/en"regex:dict={"date":r"(\d{1,2}\/\d{1,2}\/20\d{2})",}
[docs]defread(self)->pd.DataFrame:"""Read data from source."""data=request_json(self.source_url)df=self._parse_data(data)returndf
[docs]def_parse_data(self,data:dict)->pd.DataFrame:"""Parse data."""count=clean_count(data["samples_collected"])date=extract_clean_date(data["screen_updated_times"]["toplevel_page_acf-options-statistics"],self.regex["date"],"%d/%m/%Y")df={"Date":[date],"Daily change in cumulative total":[count],}returnpd.DataFrame(df)
[docs]defpipeline(self,df:pd.DataFrame)->pd.DataFrame:"""Pipeline for data."""returndf.pipe(self.pipe_metadata)
[docs]defexport(self):"""Export data to CSV."""df=self.read().pipe(self.pipeline)self.export_datafile(df,attach=True)