ELRMileages.collect_mileage_file

ELRMileages.collect_mileage_file(elr, parsed=True, confirmation_required=True, dump_it=False, verbose=False)[source]

Collects the mileage file for the specified ELR from the source web page.

Parameters:
  • elr (str) – The ELR for which the mileage file is requested (e.g. 'CJD', 'MLA', 'FED').

  • parsed (bool) – Whether to parse the scraped mileage data; defaults to True.

  • confirmation_required (bool) – Whether user confirmation is required before proceeding; defaults to True.

  • dump_it (bool) – Whether to save the collected data as a pickle file; defaults to False.

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

Returns:

A dictionary containing the mileage file for the specified ELR.

Return type:

dict

Note

  • In some cases, mileages may be unknown and thus left blank (e.g. 'ANI2, Orton Junction with ROB (~3.05)').

  • Mileages in parentheses are not on that ELR but are included for reference (e.g., 'ANL, (8.67) NORTHOLT [London Underground]').

  • As with the main ELR list, mileages preceded by a tilde (~) are approximate.

Examples:

>>> from pyrcs.line_data import ELRMileages  # from pyrcs import ELRMileages
>>> em = ELRMileages()
>>> gam_mileage_file = em.collect_mileage_file(elr='GAM')
To collect mileage file of "GAM"
? [No]|Yes: yes
>>> type(gam_mileage_file)
dict
>>> list(gam_mileage_file.keys())
['ELR', 'Line', 'Sub-Line', 'Mileage', 'Notes']
>>> gam_mileage_file['Mileage']
   Mileage Mileage_Note Miles_Chains  ... Link_1 Link_1_ELR Link_1_Mile_Chain
0   8.1518                      8.69  ...   None
1  10.0264                     10.12  ...   None
[2 rows x 8 columns]
>>> xrc2_mileage_file = em.collect_mileage_file(elr='XRC2')
To collect mileage file of "XRC2"
? [No]|Yes: yes
>>> xrc2_mileage_file['Mileage']
  Mileage Mileage_Note  ... Link_1_ELR Link_1_Mile_Chain
0  9.0158     14.629km  ...
1  9.0447     14.893km  ...
2  9.0557     14.994km  ...
[3 rows x 8 columns]
>>> xre_mileage_file = em.collect_mileage_file(elr='XRE')
To collect mileage file of "XRE"
? [No]|Yes: yes
>>> xre_mileage_file['Mileage']
  Mileage Mileage_Note  ... Link_2_ELR Link_2_Mile_Chain
0  7.0073     11.333km  ...
1  7.0174     11.425km  ...
2  9.0158     14.629km  ...
3  9.0198     14.666km  ...
4  9.0389     14.840km  ...
5  9.0439   (14.886)km  ...
6  9.0540   (14.978)km  ...
[7 rows x 11 columns]
>>> mor_mileage_file = em.collect_mileage_file(elr='MOR')
To collect mileage file of "MOR"
? [No]|Yes: yes
>>> type(mor_mileage_file['Mileage'])
dict
>>> list(mor_mileage_file['Mileage'].keys())
['Original measure', 'Later measure']
>>> mor_mileage_file['Mileage']['Original measure']
  Mileage Mileage_Note Miles_Chains  ...        Link_1 Link_1_ELR Link_1_Mile_Chain
0  0.0000                      0.00  ...  SWA (215.18)        SWA            215.18
1  0.0792                      0.36  ...          None
2  0.1716                      0.78  ...          None
3  1.1166                      1.53  ...          None
4  2.0066                      2.03  ...          None
5  2.0836                      2.38  ...          None
6                                    ...          None
7  3.0462                      3.21  ...   SDI2 (2.79)       SDI2              2.79
[8 rows x 8 columns]
>>> mor_mileage_file['Mileage']['Later measure']
  Mileage Mileage_Note Miles_Chains  ...        Link_1 Link_1_ELR Link_1_Mile_Chain
0  0.0000                      0.00  ...  SWA (215.26)        SWA            215.26
1  0.0176                      0.08  ...  SWA (215.18)        SWA            215.18
2  0.0968                      0.44  ...          None
3  1.0132                      1.06  ...          None
4  1.1342                      1.61  ...          None
5  2.0242                      2.11  ...          None
6  2.1012                      2.46  ...          None
7                                    ...          None
8  3.0638                      3.29  ...   SDI2 (2.79)       SDI2              2.79
[9 rows x 8 columns]
>>> fed_mileage_file = em.collect_mileage_file(elr='FED')
To collect mileage file of "FED"
? [No]|Yes: yes
>>> type(fed_mileage_file['Mileage'])
dict
>>> list(fed_mileage_file['Mileage'].keys())
['Current route', 'Original route']
>>> fed_mileage_file['Mileage']['Current route']
   Mileage Mileage_Note  ... Link_1_ELR Link_1_Mile_Chain
0  83.1254               ...        FEL
1  84.0198               ...
2  84.1430               ...
3  84.1540               ...
4  85.0484               ...
5  85.1122               ...
6  85.1188               ...        TFN              2.13
[7 rows x 8 columns]
>>> fed_mileage_file['Mileage']['Original route']
  Mileage Mileage_Note Miles_Chains  ...       Link_1 Link_1_ELR Link_1_Mile_Chain
0  0.0000                      0.00  ...  FEL (84.22)        FEL             84.22
1  1.0176                      1.08  ...         None
2  1.1540                      1.70  ...         None
3  1.1694                      1.77  ...         None
[4 rows x 8 columns]