TrackDiagrams.collect_catalogue

TrackDiagrams.collect_catalogue(confirmation_required=True, verbose=False)[source]

Collects the catalogue of sample railway track diagrams 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 the railway track diagram catalogue and the date it was last updated, or None if no data is collected.

Return type:

dict | None

Examples:

>>> from pyrcs.line_data import TrackDiagrams  # from pyrcs import TrackDiagrams
>>> td = TrackDiagrams()
>>> track_diagrams_catalog = td.collect_catalogue()
To collect the catalogue of track diagrams
? [No]|Yes: yes
>>> type(track_diagrams_catalog)
dict
>>> list(track_diagrams_catalog.keys())
['Track diagrams', 'Last updated date']
>>> td_dat = track_diagrams_catalog['Track diagrams']
>>> type(td_dat)
dict
>>> 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].head()
                             Description                                         FileURL
0  South Central area (1985) 10.4Mb file  http://www.railwaycodes.org.uk/line/track/d...
1   South Eastern area (1976) 5.4Mb file  http://www.railwaycodes.org.uk/line/track/d...