LocationIdentifiers.collect_loc_id¶
- LocationIdentifiers.collect_loc_id(initial, confirmation_required=True, verbose=False, raise_error=False)[source]¶
Collects CRS, NLC, TIPLOC, STANME and STANOX codes for a given initial letter.
- Parameters:
initial (str) – The initial letter (e.g.
'a'
,'z'
) of a location name.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 data of locations whose names start with the given initial letter, along with the date of the last update.
- Return type:
dict
Examples:
>>> from pyrcs.line_data import LocationIdentifiers >>> # from pyrcs import LocationIdentifiers >>> lid = LocationIdentifiers() >>> loc_a_codes = lid.collect_loc_id(initial='a') To collect data of CRS, NLC, TIPLOC and STANOX codes beginning with "A" ? [No]|Yes: yes >>> type(loc_a_codes) dict >>> list(loc_a_codes.keys()) ['A', 'Additional notes', 'Last updated date'] >>> loc_a_codes_dat = loc_a_codes['A'] >>> type(loc_a_codes_dat) pandas.core.frame.DataFrame >>> loc_a_codes_dat.head() Location CRS ... STANME_Note STANOX_Note 0 1999 Reorganisations ... 1 A1 ... 2 A463 Traded In ... 3 A483 Road Scheme Supervisors Closed ... 4 Aachen ... [5 rows x 12 columns]