Depots.collect_tops_codes¶
- Depots.collect_tops_codes(confirmation_required=True, verbose=False, raise_error=False)[source]¶
Collects two-character TOPS codes from the source web page.
- Parameters:
confirmation_required (bool) – Whether user confirmation is required; if
confirmation_required=True
(default), prompts the user for confirmation before proceeding with data collection.verbose (bool | int) – Whether to print relevant information to the console; defaults to
False
.raise_error (bool) – Whether to raise the provided exception; if
raise_error=False
(default), the error will be suppressed.
- Returns:
A dictionary containing the two-character TOPS codes and the date they were last updated, or
None
if no data is collected.- Return type:
dict | None
Examples:
>>> from pyrcs.other_assets import Depots # from pyrcs import Depots >>> depots = Depots() >>> tct_codes = depots.collect_tops_codes() To collect data of two character TOPS codes ? [No]|Yes: yes >>> type(tct_codes) dict >>> list(tct_codes.keys()) ['Two character TOPS codes', 'Last updated date'] >>> depots.KEY_TO_TOPS 'Two character TOPS codes' >>> tct_codes_dat = tct_codes[depots.KEY_TO_TOPS] >>> type(tct_codes_dat) pandas.core.frame.DataFrame >>> tct_codes_dat.head() Code ... Notes 0 AB ... Closed 1987 1 AB ... 2 AC ... Became WH from 1994 3 AC ... 4 AD ... [5 rows x 5 columns]