Skip to content

Commit 5ba4fd5

Browse files
committed
stop scraping unused table
1 parent 38bdd50 commit 5ba4fd5

2 files changed

Lines changed: 30 additions & 40 deletions

File tree

src/acquisition/rvdss/pull_historic.py

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ def extract_captions_of_interest(soup):
107107
are missing. In that case, use the figure captions
108108
"""
109109
captions = soup.find_all('summary')
110-
111110
table_identifiers = ["respiratory","number","positive","abbreviation"]
112111

113112
# For every caption, check if all of the table identifiers are missing. If they are,
@@ -121,7 +120,7 @@ def extract_captions_of_interest(soup):
121120
for i in range(len(captions)):
122121
caption = captions[i]
123122

124-
matches = ["period","abbreviation","cumulative", "compared"] #skip historic comparisons and cumulative tables
123+
matches = ["period","abbreviation","cumulative", "compared","number"] #skip historic comparisons and cumulative tables
125124
# remove any captions with a class or that are uninformative
126125
if any(x in caption.text.lower() for x in matches) or caption.has_attr('class') or all(name not in caption.text.lower() for name in table_identifiers):
127126
remove_list.append(caption)
@@ -236,30 +235,30 @@ def create_detections_table(table,modified_date,week_number,week_end_date,start_
236235
table.columns =[re.sub(" ","_",col) for col in table.columns]
237236
return(table)
238237

239-
def create_number_detections_table(table,modified_date,start_year):
240-
week_columns = table.columns.get_indexer(table.columns[~table.columns.str.contains('week')])
238+
# def create_number_detections_table(table,modified_date,start_year):
239+
# week_columns = table.columns.get_indexer(table.columns[~table.columns.str.contains('week')])
241240

242-
for index in week_columns:
243-
new_name = abbreviate_virus(table.columns[index]) + " positive_tests"
244-
table.rename(columns={table.columns[index]: new_name}, inplace=True)
245-
table[table.columns[index]] = table[table.columns[index]].replace(r'\s', '', regex=True).astype('int')
241+
# for index in week_columns:
242+
# new_name = abbreviate_virus(table.columns[index]) + " positive_tests"
243+
# table.rename(columns={table.columns[index]: new_name}, inplace=True)
244+
# table[table.columns[index]] = table[table.columns[index]].replace(r'\s', '', regex=True).astype('int')
246245

247246

248-
if "week end" not in table.columns:
249-
week_ends = [get_report_date(week,start_year) for week in table["week"]]
250-
table.insert(1,"week end",week_ends)
247+
# if "week end" not in table.columns:
248+
# week_ends = [get_report_date(week,start_year) for week in table["week"]]
249+
# table.insert(1,"week end",week_ends)
251250

252-
table = table.assign(**{'issue': modified_date,
253-
'geo_type': "nation",
254-
'geo_value': "ca"})
251+
# table = table.assign(**{'issue': modified_date,
252+
# 'geo_type': "nation",
253+
# 'geo_value': "ca"})
255254

256-
table=table.rename(columns={'week end':"time_value"})
257-
table.columns =[re.sub(" ","_",col) for col in table.columns]
258-
table['time_value'] = [check_date_format(d) for d in table['time_value']]
255+
# table=table.rename(columns={'week end':"time_value"})
256+
# table.columns =[re.sub(" ","_",col) for col in table.columns]
257+
# table['time_value'] = [check_date_format(d) for d in table['time_value']]
259258

260-
table=table.rename(columns={'week':"epiweek"})
261-
table['epiweek'] = [get_report_date(week, start_year,epi=True) for week in table['epiweek']]
262-
return(table)
259+
# table=table.rename(columns={'week':"epiweek"})
260+
# table['epiweek'] = [get_report_date(week, start_year,epi=True) for week in table['epiweek']]
261+
# return(table)
263262

264263
def create_percent_positive_detection_table(table,modified_date,start_year, flu=False,overwrite_weeks=False):
265264
table = deduplicate_rows(table)
@@ -499,10 +498,10 @@ def fetch_one_season_from_report(url):
499498
respiratory_detection_table_exists = True
500499
respiratory_detection_table = create_detections_table(table,modified_date,current_week,current_week_end,season[0])
501500
respiratory_detection_table = respiratory_detection_table.set_index(['epiweek', 'time_value', 'issue', 'geo_type', 'geo_value'])
502-
elif "number" in caption.text.lower():
503-
number_table_exists = True
504-
number_detections_table = create_number_detections_table(table,modified_date,season[0])
505-
number_detections_table = number_detections_table.set_index(['epiweek', 'time_value', 'issue', 'geo_type', 'geo_value'])
501+
# elif "number" in caption.text.lower():
502+
# number_table_exists = True
503+
# number_detections_table = create_number_detections_table(table,modified_date,season[0])
504+
# number_detections_table = number_detections_table.set_index(['epiweek', 'time_value', 'issue', 'geo_type', 'geo_value'])
506505
elif "positive" in caption.text.lower():
507506
positive_table_exists = True
508507
flu = " influenza" in caption.text.lower()
@@ -549,15 +548,15 @@ def fetch_one_season_from_report(url):
549548
all_positive_tables=pd.concat([all_positive_tables,combined_positive_tables])
550549
del combined_positive_tables
551550
del pos_table
552-
if number_table_exists:
553-
if not number_detections_table.index.isin(all_number_tables.index).any():
554-
all_number_tables=pd.concat([all_number_tables,number_detections_table])
555-
del number_detections_table
551+
# if number_table_exists:
552+
# if not number_detections_table.index.isin(all_number_tables.index).any():
553+
# all_number_tables=pd.concat([all_number_tables,number_detections_table])
554+
# del number_detections_table
556555

557556
return {
558557
"respiratory_detection": all_respiratory_detection_tables,
559-
"positive": all_positive_tables,
560-
"count": all_number_tables,
558+
"positive": all_positive_tables
559+
#"count": all_number_tables,
561560
}
562561

563562
def fetch_archived_dashboard_dates(archive_url):

src/acquisition/rvdss/utils.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -279,16 +279,7 @@ def duplicate_provincial_detections(data):
279279

280280
def combine_tables(data_dict):
281281
num_tables = len(data_dict)
282-
if(num_tables==3):
283-
count=data_dict["count"]
284-
positive=data_dict["positive"]
285-
detections=data_dict["respiratory_detection"]
286-
287-
detections = expand_detections_columns(detections)
288-
dat = detections.combine_first(positive)
289-
dat = dat.combine_first(count)
290-
dat = duplicate_provincial_detections(dat)
291-
elif(num_tables==2):
282+
if(num_tables==2):
292283
positive=data_dict["positive"]
293284
detections=data_dict["respiratory_detection"]
294285

0 commit comments

Comments
 (0)