utils

Utilities - Helper functions.

Specification of resource homepage

homepage_url()

Specify the homepage URL of the data source.

Data converters

mile_chain_to_nr_mileage(miles_chains)

Convert mileage data in the form ‘<miles>.<chains>’ to Network Rail mileage.

nr_mileage_to_mile_chain(str_mileage)

Convert Network Rail mileage to the form ‘<miles>.<chains>’.

nr_mileage_str_to_num(str_mileage)

Convert string-type Network Rail mileage to numerical-type one.

nr_mileage_num_to_str(num_mileage)

Convert numerical-type Network Rail mileage to string-type one.

nr_mileage_to_yards(nr_mileage)

Convert Network Rail mileages to yards.

yards_to_nr_mileage(yards)

Convert yards to Network Rail mileages.

shift_num_nr_mileage(nr_mileage, shift_yards)

Shift Network Rail mileage by given yards.

year_to_financial_year(date)

Convert calendar year of a given date to Network Rail financial year.

Data parsers

parse_tr(header, trs)

Parse a list of parsed HTML <tr> elements.

parse_table(source[, parser])

Parse HTML <tr> elements for creating a data frame.

parse_location_name(location_name)

Parse location name (and its associated note).

parse_date(str_date[, as_date_type])

Parse a date.

Retrieval of useful information

get_site_map([update, …])

Fetch the site map from the package data.

get_last_updated_date(url[, parsed, …])

Get last update date.

get_catalogue(page_url[, update, …])

Get the catalogue for a class.

get_category_menu(menu_url[, update, …])

Get a menu of the available classes.

Rectification of location names

fetch_loc_names_repl_dict([k, regex, …])

Create a dictionary for rectifying location names.

update_loc_names_repl_dict(new_items, regex)

Update the location-names replacement dictionary in the package data.

Data fixers

fix_num_stanox(stanox_code)

Fix ‘STANOX’ if it is loaded as numbers.

fix_nr_mileage_str(nr_mileage)

Fix Network Rail mileage.

Miscellaneous utilities

print_connection_error([verbose])

Print a message about unsuccessful attempts to establish a connection to the Internet.

print_conn_err([update, verbose])

Print a message about unsuccessful attempts to establish a connection to the Internet for an instance of a class.

is_str_float(str_val)

Check if a string-type variable can express a float-type value.

is_internet_connected()

Check the Internet connection.