Telegraph.collect_codes¶
- Telegraph.collect_codes(confirmation_required=True, verbose=False, raise_error=False)[source]¶
Collects data of telegraph code words 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 telegraph code words and the date they were last updated, or
None
if no data is collected.- Return type:
dict | None
Examples:
>>> from pyrcs.other_assets import Telegraph # from pyrcs import Telegraph >>> tel = Telegraph() >>> tel_codes = tel.collect_codes() To collect data of telegraphic codes ? [No]|Yes: yes >>> type(tel_codes) dict >>> list(tel_codes.keys()) ['Telegraphic codes', 'Last updated date'] >>> tel.KEY 'Telegraphic codes' >>> tel_codes_dat = tel_codes[tel.KEY] >>> type(tel_codes_dat) dict >>> list(tel_codes_dat.keys()) ['Official codes', 'Unofficial codes'] >>> tel_official_codes = tel_codes_dat['Official codes'] >>> type(tel_official_codes) pandas.core.frame.DataFrame >>> tel_official_codes.head() Code ... In use 0 ABACK ... cross industry term used in 1939 1 ABASE ... GWR, 1939 2 ABREAST ... GWR, 1939 / Railway Executive, 1950 3 ABREAST ... British Transport Commission, 1958 4 ABSENT ... GWR, 1939 [5 rows x 3 columns] >>> tel_unofficial_codes = tel_codes_dat['Unofficial codes'] >>> type(tel_unofficial_codes) pandas.core.frame.DataFrame >>> tel_unofficial_codes.head() Code Unofficial description 0 CRANKEX [See KRANKEX] 1 DRUNKEX Saturday night special train (usually a DMU) t... 2 GYFO Strongly urge all speed ('Get your finger out') 3 KRANKEX Special train with interesting routing or trac... 4 MYSTEX Special excursion going somewhere no one reall...