def extract_train_info(f_input):
    """Extract the train schedule information from the ATOC Timetable data as described in:
    http://data.atoc.org/sites/all/themes/atoc/files/RSPS5046.pdf

    Input parameters:
    -----------------
    f_input: String text with details of a train

    Result:
    -------
    train_dict: Dictionary containing details of: 
        - train_id - String unique train ID
        - date_from - Date from which the train runs in the year
        - date_to - Date to which the train runs in the year
        - cargo_type - Identify if it is an ordinary train or express train or bus or other
        - power_type - Identify if it is deisel or electric or HST or other
        - day (mon - sun) - Binary (0 or 1) to indicate if train runs on the day of the week
        - stp_indicator - Indicates if the train is cancelled, new, permanent or overlay  
    """
    name = f_input.split()
    transaction_type = name[0][2]
    train_id = name[0][3:9]
    Date_from = name[0][9:15]
    Date_to = name[0][15:21]
    Mon = int(name[0][21])
    Tue = int(name[0][22])
    Wed = int(name[0][23])
    Thu = int(name[0][24])
    Fri = int(name[0][25])
    Sat = int(name[0][26])
    Sun = int(name[0][27])

    if 'POL' in f_input or '1OL' in f_input or 'POU' in f_input or '1OU' in f_input or 'POO' in f_input or '1OO' in f_input or 'POS' in f_input or '1OS' in f_input or 'POW' in f_input or '1OW' in f_input:
        cargo_type = 'OrdP'
    elif 'PXC' in f_input or '1XC' in f_input or 'PXD' in f_input or '1XD' in f_input or 'PXI' in f_input or '1XI' in f_input or 'PXR' in f_input or '1XR' in f_input or 'PXU' in f_input or '1XU' in f_input or 'PXX' in f_input or '1XX' in f_input or 'PXZ' in f_input or '1XZ' in f_input:
        cargo_type = 'ExpP'
    elif 'BBR' in f_input or '5BR' in f_input or 'BBS' in f_input or '5BS' in f_input:
        cargo_type = 'BUS'
    else:
        cargo_type = 'Other'

    if 'DMU' in f_input:
        Power_type = 'DMU'
    elif 'EMU' in f_input:
        Power_type = 'EMU'
    elif 'HST' in f_input:
        Power_type = 'HST'
    else:
        Power_type = 'Other'

    STP_indicator = name[-1][0]

    train_dict = {
                    'transaction_type':transaction_type,
                    'train_id':train_id, 
                    'date_from':Date_from,
                    'date_to':Date_to,
                    'cargo_type': cargo_type, 
                    'mon':Mon, 
                    'tue':Tue,
                    'wed':Wed, 
                    'thu':Thu, 
                    'fri':Fri, 
                    'sat':Sat, 
                    'sun':Sun, 
                    'power_type':Power_type, 
                    'stp_indicator':STP_indicator
                }
    return train_dict