brokenspoke_analyzer.core.downloader module

Define functions used to download files.

async brokenspoke_analyzer.core.downloader.download_2010_census_blocks(session, output_dir, fips)

Download a 2010 census tabulation block code for a specific state.

Return type:

None

async brokenspoke_analyzer.core.downloader.download_2021_census_blocks(session, output_dir, state_fips)

Download a 2021 census tabulation block code for a specific state.

Return type:

None

async brokenspoke_analyzer.core.downloader.download_census_waterblocks(session, output_dir)

Download the census waterblocks.

Return type:

None

async brokenspoke_analyzer.core.downloader.download_city_speed_limits(session, output_dir)

Download the city speed limits.

Return type:

None

async brokenspoke_analyzer.core.downloader.download_file(session, url, output, skip_existing=True)

Download payload stream into a file.

Parameters:
  • session (ClientSession) – aiohttp session

  • url (str) – request URL

  • output (Path) – path where to write the file

  • skip_existing (bool) – skip the download if the output file already exists

Return type:

None

async brokenspoke_analyzer.core.downloader.download_lodes_data(session, output_dir, state, part, year)

Download employment data from the US census website: https://lehd.ces.census.gov/.

LODES stands for LEHD Origin-Destination Employment Statistics.

OD means Origin-Data, which represents the jobs that are associated with both a home census block and a work census block.

The filename is composed of the following parts: [ST]_od_[PART]_[TYPE]_[YEAR].csv.gz. :rtype: None

  • [ST] = lowercase, 2-letter postal code for a chosen state

  • [PART] = Part of the state file, can have a value of either “main” or

    “aux”. Complimentary parts of the state file, the main part includes jobs with both workplace and residence in the state and the aux part includes jobs with the workplace in the state and the residence outside of the state.

  • [TYPE] = Job Type, can have a value of “JTOO” for All Jobs, “JT01” for

    Primary Jobs, “JT02” for All Private Jobs, “JT03” for Private Primary Jobs, “JT04” for All Federal Jobs, or “JT05” for Federal Primary Jobs.

  • [YEAR] = Year of job data. Can have the value of 2002-2020 for most

    states.

As an example, the main OD file of Primary Jobs in 2007 for California would be the file: ca_od_main_JTO1_2007.csv.gz.

More information about the formast can be found on the website: https://lehd.ces.census.gov/data/#lodes.

async brokenspoke_analyzer.core.downloader.download_state_speed_limits(session, output_dir)

Download the state speed limits.

Return type:

None

async brokenspoke_analyzer.core.downloader.fetch_text(session, url, params=None)

Fetch the data from a URL as text.

Parameters:
  • session (ClientSession) – aiohttp session

  • url (str) – request URL

  • params (Optional[dict[str, str]]) – request parameters, defaults to None

Return type:

str

Returns:

the data from a URL as text.