SignalBoxes.collect_bell_codes¶
- SignalBoxes.collect_bell_codes(confirmation_required=True, verbose=False, raise_error=False)[source]¶
Collects data of bell 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 data of bell codes and the date when they were last updated, or
Noneif no data is collected.- Return type:
dict | None
Examples:
>>> from pyrcs.other_assets import SignalBoxes # from pyrcs import SignalBoxes >>> sb = SignalBoxes() >>> sb_bell_codes: dict = sb.collect_bell_codes(verbose=True) Proceed with collecting data of "Bell codes"? [No]|Yes: yes Collecting the data ... Done. >>> list(sb_bell_codes) ['Bell codes', 'Last updated date'] >>> sb_bell_codes_dict: dict = sb_bell_codes.get('Bell codes') >>> list(sb_bell_codes_dict) ['Network Rail codes', 'Southern Railway codes', 'Lancashire & Yorkshire Railway codes'] >>> sb_nr_bell_codes: dict = sb_bell_codes_dict.get('Network Rail codes') >>> list(sb_nr_bell_codes) ['Codes', 'Notes'] >>> sb_nr_bell_codes_df = sb_nr_bell_codes.get('Codes') >>> sb_nr_bell_codes_df.shape (69, 2) >>> sb_nr_bell_codes_df.head() Code Meaning 0 1 Call attention 1 1-1 Answer telephone [withdrawn 2007] 2 1-1-6 Police assistance urgently required 3 1-2 Signaller required on telephone [added 2007] 4 1-2-1 Train approaching