Viaducts.collect_codes

Viaducts.collect_codes(page_no, confirmation_required=True, verbose=False, raise_error=False)[source]

Collect data of railway viaducts for a specific page number from the source web page.

This method coordinates the retrieval process by identifying the target URL from the catalogue and calling the base data collection method with user confirmation.

Parameters:
  • page_no (int | str) – The page number where data is collected from; valid values are 1 to 6.

  • confirmation_required (bool) – Whether user confirmation is required; if True (default), prompts the user before proceeding.

  • verbose (bool | int) – Whether to print status information to the console. Defaults to False.

  • raise_error (bool) – Whether to raise exceptions encountered during retrieval; if False (default), errors are suppressed.

Returns:

A dictionary containing the viaduct data and the last updated date.

Return type:

dict | None

Examples:

>>> from pyrcs.other_assets import Viaducts  # from pyrcs import Viaducts

>>> vdct = Viaducts()

>>> viaducts_page_1: dict = vdct.collect_codes(page_no=1, verbose=True)
Proceed with collecting data of railway viaducts (Page 1 (A-C))?
 [No]|Yes: yes
Collecting the data ... Done.

>>> list(viaducts_page_1)
['Page 1 (A-C)', 'Last updated date']

>>> viaducts_page_1_data = viaducts_page_1['Page 1 (A-C)']

>>> type(viaducts_page_1_data)
pandas.DataFrame
>>> viaducts_page_1_data.shape
(631, 7)
>>> viaducts_page_1_data.head()
       Name  ... Spans/ arches
0  7 Arches  ...             7
1   36 Arch  ...            36
2   42 Arch  ...
3       A46  ...
4      A413  ...
[5 rows x 7 columns]