<jupyter_start><jupyter_text>Configuration_Initial steps to get the notebook ready to play nice with our repository. Do not delete this section._ Code formatting with [black](https://pypi.org/project/nb-black/).<jupyter_code>%load_ext lab_black<jupyter_output><empty_output><jupyter_text>Add our `utils` directory to the system's `$PATH` so we can import Python files from sibling directories.<jupyter_code>import os
import pathlib
this_dir = pathlib.Path(os.path.abspath(""))
data_dir = this_dir / "data"
import re
import json
import pytz
import glob
import requests
import pandas as pd
from datetime import datetime
from bs4 import BeautifulSoup<jupyter_output><empty_output><jupyter_text>Download Retrieve the page<jupyter_code>url = "https://infogram.com/1pe66wmyjnmvkrhm66x9362kp3al60r57ex"
page = requests.get(url)<jupyter_output><empty_output><jupyter_text>Parse<jupyter_code>soup = BeautifulSoup(page.content, "html.parser")<jupyter_output><empty_output><jupyter_text>Find script tag with the Infogram data<jupyter_code>for elem in soup(text=re.compile(r"window.infographicData")):
    script = elem
stripped_script = script.replace("window.infographicData=", "")
stripped_script = stripped_script.rstrip(";")
data = json.loads(stripped_script)
cities = data["elements"]["content"]["content"]["entities"][
    "b26b9acd-b036-40bc-bbbe-68667dd338e4"
]["props"]["chartData"]["data"][0]
not_empty = [ele for ele in cities if ele != [""]]<jupyter_output><empty_output><jupyter_text>Convert to dataframe<jupyter_code>df = pd.DataFrame(not_empty, columns=["area", "confirmed_cases"])<jupyter_output><empty_output><jupyter_text>Get timestamp<jupyter_code>timestamp = data["updatedAt"]
latest_date = pd.to_datetime(timestamp).date()
df.insert(0, "county", "Butte")
df["county_date"] = latest_date<jupyter_output><empty_output><jupyter_text>Vet<jupyter_code>try:
    assert not len(df) > 6
except AssertionError:
    raise AssertionError("Butte County's city scraper has additional rows")
try:
    assert not len(df) < 6
except AssertionError:
    raise AssertionError("Butte's city scraper is missing rows")<jupyter_output><empty_output><jupyter_text>Export Mark the current date<jupyter_code>tz = pytz.timezone("America/Los_Angeles")
today = datetime.now(tz).date()
slug = "butte"
df.to_csv(data_dir / slug / f"{today}.csv", index=False)<jupyter_output><empty_output><jupyter_text>Combine<jupyter_code>csv_list = [
    i
    for i in glob.glob(str(data_dir / slug / "*.csv"))
    if not str(i).endswith("timeseries.csv")
]
df_list = []
for csv in csv_list:
    if "manual" in csv:
        df = pd.read_csv(csv, parse_dates=["date"])
    else:
        file_date = csv.split("/")[-1].replace(".csv", "")
        df = pd.read_csv(csv, parse_dates=["county_date"])
        df["date"] = file_date
    df_list.append(df)
df = pd.concat(df_list).sort_values(["date", "area"])
df.to_csv(data_dir / slug / "timeseries.csv", index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13826910074374577, 'fraction_numerical': 0.012508451656524679, 'mean_word_length': 6.705729166666667, 'pattern_counts': {'":': 0, '<': 42, '<?xml version=': 0, '>': 42, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '403108', 'license': 'MIT', 'n_tokens_mistral': 1085, 'n_tokens_neox': 1057, 'n_words': 200, 'path': 'places/butte.ipynb', 'repo_name': 'datadesk/california-coronavirus-scrapers', 'size': '2958'}