TrackDiagrams.fetch_catalogue¶
- TrackDiagrams.fetch_catalogue(update=False, dump_dir=None, verbose=False, **kwargs)[source]¶
Fetch the catalogue of railway track diagrams.
This method retrieves the structured track diagram catalogue either from a local file cache or by parsing the live online platform source.
- Parameters:
update (bool) – Whether to check for updates to the package data. Defaults to
False.dump_dir (str | None) – The path to a directory where the data file will be saved. Defaults to
None.verbose (bool | int) – Whether to print relevant information to the console. Defaults to
False.
- Returns:
A dictionary containing the catalogue of railway track diagrams and the date it was last updated.
- Return type:
dict
Examples:
>>> from pyrcs.line_data import TrackDiagrams # from pyrcs import TrackDiagrams >>> td = TrackDiagrams() >>> track_diagrams_catalogue = td.fetch_catalogue() >>> type(track_diagrams_catalogue) dict >>> list(track_diagrams_catalogue.keys()) ['Track diagrams', 'Last updated date'] >>> td_dat = track_diagrams_catalogue['Track diagrams'] >>> list(td_dat.keys()) ['Main line diagrams', 'Tram systems', 'London Underground', 'Miscellaneous'] >>> main_line_diagrams = td_dat['Main line diagrams'] >>> type(main_line_diagrams) tuple >>> type(main_line_diagrams[1]) pandas.core.frame.DataFrame >>> main_line_diagrams[1] description file_url 0 South Central area(1985)10.4Mb file http://www.railwaycodes.org.uk/line/track/... 1 South Eastern area(1976)5.4Mb file http://www.railwaycodes.org.uk/line/track/...