compare-license-lists.py
def compare_license_lists(o365_dict, opm_dict):
    """This function computes a symmetric difference for each license list type and writes the results to Excel files

    Parameters
    ----------
    o365_dict (dictionary): O365's license lists dictionary
    opm_dict (dictionary): OPM's license lists dictionary
    """
    # Open text file to store comparison summary
    f = open(r'{}\comparison_summary.txt'.format(DATE), 'w')

    for k in o365_dict.keys():
        # Store license type DataFrame ina variable (for readability)
        o365_df = o365_dict[k]
        opm_df = opm_dict[k]
        
        # Compute symmetric difference        
        res = o365_df.merge(opm_df, 
                            how='outer', 
                            left_on='User principal name', 
                            right_on='Email', 
                            suffixes=('_o365', '_opm'), 
                            indicator='source'
                            )[['Department', 'Display name', 'First name_o365', 'Last name_o365', 'Licenses', 'User principal name', 
                            'When created', 'Cabinet', 'Last name_opm', 'First name_opm', 'Email', 'Essentials License (Project Plan Essential)',
                            'Professional (Project Plan 3)', 'Power BI', 'Premium (Project Plan 5)', 'Owner', 'Issue Date', 'source']]
        symmetric_diff_df = res.loc[res['source'] != 'both']

        # Make clear which license list the difference is from
        symmetric_diff_df.replace({'source': {'left_only': 'o365', 'right_only': 'opm'}}, inplace=True)

        # Write summary of comparison to file object for comparison_summary
        o365_minus_opm_len = symmetric_diff_df[symmetric_diff_df['source'] == 'o365'].shape[0]
        opm_minus_o365_len = symmetric_diff_df[symmetric_diff_df['source'] == 'opm'].shape[0]
        str_2_write = '{}:\n\t O365 - OPM = {}\n\t OPM - O365 = {}\n'.format(k, o365_minus_opm_len, opm_minus_o365_len)
        f.write(str_2_write)

        # Write symmetric_diff_df to Excel file
        symmetric_diff_df.to_excel(r'{}\{}_diffs.xlsx'.format(DATE, k), index=False)
    
    # Close file object for comparison_summary
    f.close()

    return
This function computes a symmetric difference for each license list type and writes the results to Excel files

    Parameters
    ----------
    o365_dict (dictionary): O365's license lists dictionary
    opm_dict (dictionary): OPM's license lists dictionary
    
This function computes a symmetric difference for each license list type and writes the results to Excel files
Parameters


This function computes a symmetric difference for each license list type and writes the results to Excel files Parameters
def compare_license_lists(o365_dict, opm_dict):
    f = open(r'{}\comparison_summary.txt'.format(DATE), 'w')
    for k in o365_dict.keys():
        o365_df = o365_dict[k]
        opm_df = opm_dict[k]
        res = o365_df.merge(opm_df, 
                            how='outer', 
                            left_on='User principal name', 
                            right_on='Email', 
                            suffixes=('_o365', '_opm'), 
                            indicator='source'
                            )[['Department', 'Display name', 'First name_o365', 'Last name_o365', 'Licenses', 'User principal name', 
                            'When created', 'Cabinet', 'Last name_opm', 'First name_opm', 'Email', 'Essentials License (Project Plan Essential)',
                            'Professional (Project Plan 3)', 'Power BI', 'Premium (Project Plan 5)', 'Owner', 'Issue Date', 'source']]
        symmetric_diff_df = res.loc[res['source'] != 'both']
        symmetric_diff_df.replace({'source': {'left_only': 'o365', 'right_only': 'opm'}}, inplace=True)
        o365_minus_opm_len = symmetric_diff_df[symmetric_diff_df['source'] == 'o365'].shape[0]
        opm_minus_o365_len = symmetric_diff_df[symmetric_diff_df['source'] == 'opm'].shape[0]
        str_2_write = '{}:\n\t O365 - OPM = {}\n\t OPM - O365 = {}\n'.format(k, o365_minus_opm_len, opm_minus_o365_len)
        f.write(str_2_write)
        symmetric_diff_df.to_excel(r'{}\{}_diffs.xlsx'.format(DATE, k), index=False)
    f.close()
    return
def compare_license_lists ( o365_dict , opm_dict ) : f = open ( r'{}\comparison_summary.txt' . format ( DATE ) , 'w' ) for k in o365_dict . keys ( ) : o365_df = o365_dict [ k ] opm_df = opm_dict [ k ] res = o365_df . merge ( opm_df , how = 'outer' , left_on = 'User principal name' , right_on = 'Email' , suffixes = ( '_o365' , '_opm' ) , indicator = 'source' ) [ [ 'Department' , 'Display name' , 'First name_o365' , 'Last name_o365' , 'Licenses' , 'User principal name' , 'When created' , 'Cabinet' , 'Last name_opm' , 'First name_opm' , 'Email' , 'Essentials License (Project Plan Essential)' , 'Professional (Project Plan 3)' , 'Power BI' , 'Premium (Project Plan 5)' , 'Owner' , 'Issue Date' , 'source' ] ] symmetric_diff_df = res . loc [ res [ 'source' ] != 'both' ] symmetric_diff_df . replace ( { 'source' : { 'left_only' : 'o365' , 'right_only' : 'opm' } } , inplace = True ) o365_minus_opm_len = symmetric_diff_df [ symmetric_diff_df [ 'source' ] == 'o365' ] . shape [ 0 ] opm_minus_o365_len = symmetric_diff_df [ symmetric_diff_df [ 'source' ] == 'opm' ] . shape [ 0 ] str_2_write = '{}:\n\t O365 - OPM = {}\n\t OPM - O365 = {}\n' . format ( k , o365_minus_opm_len , opm_minus_o365_len ) f . write ( str_2_write ) symmetric_diff_df . to_excel ( r'{}\{}_diffs.xlsx' . format ( DATE , k ) , index = False ) f . close ( ) return
This function computes a symmetric difference for each license list type and writes the results to Excel files
Parameters
This function computes a symmetric difference for each license list type and writes the results to Excel files Parameters
"""This function computes a symmetric difference for each license list type and writes the results to Excel files

    Parameters
    ----------
    o365_dict (dictionary): O365's license lists dictionary
    opm_dict (dictionary): OPM's license lists dictionary
    """ # Open text file to store comparison summary # Store license type DataFrame ina variable (for readability) # Compute symmetric difference         # Make clear which license list the difference is from # Write summary of comparison to file object for comparison_summary # Write symmetric_diff_df to Excel file # Close file object for comparison_summary
o365_dict
opm_dict