Stations¶
A class for collecting railway station data.
Stations.parse_current_operator (x) |
Parse ‘Operator’ column :param x: :return: |
Stations.collect_railway_station_data_by_initial (initial) |
Collect railway station data for the given initial letter. |
Stations.fetch_railway_station_data ([…]) |
Fetch railway station data from local backup. |
-
class
pyrcs.other_assets.
Stations
(data_dir=None, update=False)[source]¶ A class for collecting railway station data.
Parameters: - data_dir (str, None) – name of data directory, defaults to
None
- update (bool) – whether to check on update and proceed to update the package data, defaults to
False
Example:
from pyrcs.other_assets import Stations stn = Stations() print(stn.Name) # Stations print(stn.SourceURL) # http://www.railwaycodes.org.uk/stations/station0.shtm
-
collect_railway_station_data_by_initial
(initial, update=False, verbose=False)[source]¶ Collect railway station data for the given
initial
letter.Parameters: - initial (str) – initial letter of station data (including the station name, ELR, mileage, status, owner, operator, degrees of longitude and latitude, and grid reference) for specifying URL
- update (bool) – whether to check on update and proceed to update the package data, defaults to
False
- verbose (bool, int) – whether to print relevant information in console as the function runs, defaults to
False
Returns: railway station data for the given
initial
letter; and date of when the data was last updatedReturn type: dict
Example:
from pyrcs.other_assets import Stations stn = Stations() update = False initial = 'a' railway_station_data_a = stn.collect_railway_station_data_by_initial(initial, update) print(railway_station_data_a) # {'A': <codes>, # 'Last updated date': <date>}
-
fetch_railway_station_data
(update=False, pickle_it=False, data_dir=None, verbose=False)[source]¶ Fetch railway station data from local backup.
Parameters: - update (bool) – whether to check on update and proceed to update the package data, defaults to
False
- pickle_it (bool) – whether to replace the current package data with newly collected data, defaults to
False
- data_dir (str, None) – name of package data folder, defaults to
None
- verbose (bool, int) – whether to print relevant information in console as the function runs, defaults to
False
Returns: railway station data (incl. the station name, ELR, mileage, status, owner, operator, degrees of longitude and latitude, and grid reference) and date of when the data was last updated
Return type: dict
Example:
from pyrcs.other_assets import Stations stn = Stations() update = False pickle_it = False data_dir = None railway_station_data = stn.fetch_railway_station_data(update, pickle_it, data_dir) print(railway_station_data) # {'Railway station data': <codes>, # 'Latest update date': <date>}
- update (bool) – whether to check on update and proceed to update the package data, defaults to
- data_dir (str, None) – name of data directory, defaults to