LineNames.collect_codes

LineNames.collect_codes(confirmation_required=True, verbose=False)[source]

Collects data of railway line names and associated route data from the source web page.

Parameters:
  • confirmation_required (bool) – Whether user confirmation is required before proceeding; defaults to True.

  • verbose (bool | int) – Whether to print relevant information to the console; defaults to False.

Returns:

A dictionary containing railway line names, route data and the last update date, or None if no data is collected.

Return type:

dict | None

Examples:

>>> from pyrcs.line_data import LineNames  # from pyrcs import LineNames
>>> ln = LineNames()
>>> line_names_codes = ln.collect_codes()
To collect British railway line names
? [No]|Yes: yes
>>> type(line_names_codes)
dict
>>> list(line_names_codes.keys())
['Line names', 'Last updated date']
>>> ln.KEY
'Line names'
>>> line_names_codes_dat = line_names_codes[ln.KEY]
>>> type(line_names_codes_dat)
pandas.core.frame.DataFrame
>>> line_names_codes_dat.head()
             Line name  ... Route_note
0           Abbey Line  ...       None
1        Airedale Line  ...       None
2          Argyle Line  ...       None
3     Arun Valley Line  ...       None
4  Atlantic Coast Line  ...       None
[5 rows x 3 columns]