Stations

class pyrcs.other_assets.Stations(data_dir=None, update=False, verbose=True)[source]

A class for collecting railway station data.

Parameters:
  • data_dir (str | None) – The name of the directory for storing the data; defaults to None.

  • update (bool) – Whether to check for updates to the catalogue; defaults to False.

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

Variables:
  • catalogue (dict) – The catalogue of the data.

  • last_updated_date (str) – The date when the data was last updated.

  • data_dir (str) – The path to the directory containing the data.

  • current_data_dir (str) – The path to the current data directory.

Examples:

>>> from pyrcs.other_assets import Stations  # from pyrcs import Stations
>>> stn = Stations()
>>> stn.NAME
'Railway station data'
>>> stn.URL
'http://www.railwaycodes.org.uk/stations/station0.shtm'

Attributes

KEY

The key for accessing the data.

KEY_TO_LAST_UPDATED_DATE

The key used to reference the last updated date in the data.

KEY_TO_STN

The key for accessing the data of Mileages, operators and grid coordinates.

NAME

The name of the data.

URL

The URL of the main web page for the data.

Methods

collect_catalogue([confirmation_required, ...])

Collects the catalogue of railway station data from the source web page.

collect_locations(initial[, ...])

Collects data of railway station locations (mileages, operators and grid coordinates) for a given initial letter.

fetch_catalogue([update, dump_dir, verbose])

Fetches the catalogue of railway station data.

fetch_locations([initial, update, dump_dir, ...])

Fetches data of railway station locations (mileages, operators and grid coordinates).