def match_category(df):
    """compare data colected from matching file (match_df) with grainger and gws data pulls and create a column to tell analysts
    whether attributes from the two systems have been matched"""

    df['Matching'] = 'no'

    for row in df.itertuples():
        grainger_string = str(row.Grainger_Attribute_Name)
        gws_string = str(row.Gamut_Attribute_Name)

        #        gws_string = str(row.GWS_Attribute_Name)

        if (grainger_string) == (gws_string):
            df.at[row.Index, 'Matching'] = 'Match'
        elif (grainger_string) in (gws_string):
            df.at[row.Index, 'Matching'] = 'Potential Match'
        elif (gws_string) in (grainger_string):
            df.at[row.Index, 'Matching'] = 'Potential Match'
        elif process.isBlank(row.Grainger_Attribute_Name) == False:
            #            if process.isBlank(row.GWS_Attribute_Name) == True:

            if process.isBlank(row.Gamut_Attribute_Name) == True:
                df.at[row.Index, 'Matching'] = 'Grainger only'
        elif process.isBlank(row.Grainger_Attribute_Name) == True:
            #            if process.isBlank(row.GWS_Attribute_Name) == False:

            if process.isBlank(row.Gamut_Attribute_Name) == False:
                df.at[row.Index, 'Matching'] = 'GWS only'

    return df
def choose_definition(df):
    """pick the definition to upload to GWS based on 1. Cat specific, 2. Attribute level, 3. old Gamut definition"""

    df['Definition'] = ''
    df['Definition Source'] = ''

    for row in df.itertuples():
        cat_def = str(row.Grainger_Category_Specific_Definition)
        attr_def = str(row.Grainger_Attribute_Definition)
        gamut_def = str(row.Gamut_Attribute_Definition)

        if process.isBlank(row.Grainger_Category_Specific_Definition) == False:
            df.at[row.Index, 'Definition'] = cat_def
            df.at[row.Index,
                  'Definition Source'] = 'Grainger Category Specific'

        elif process.isBlank(row.Grainger_Attribute_Definition) == False:
            df.at[row.Index, 'Definition'] = attr_def
            df.at[row.Index,
                  'Definition Source'] = 'Grainger Attribute Definition'

        elif process.isBlank(row.Gamut_Attribute_Definition) == False:
            df.at[row.Index, 'Definition'] = gamut_def
            df.at[row.Index, 'Definition Source'] = 'Gamut Definition'

    if df.empty == False:
        df = df.drop([
            'Grainger_Attribute_Definition',
            'Grainger_Category_Specific_Definition',
            'Gamut_Attribute_Definition'
        ],
                     axis=1)  #remove unneeded columns

    return df
def match_category(df):
    """compare data colected from matching file (match_df) with grainger and gamut data pulls and create a column to tell analysts
    whether attributes from the two systems have been matched"""

    for row in df.itertuples():
        if (row.Index,
                row.Grainger_Attribute_Name) == (row.Index,
                                                 row.Gamut_Attribute_Name):
            df.at[row.Index, 'Matching'] = 'Match'
        elif process.isBlank(row.Grainger_Attribute_Name) == False:
            if process.isBlank(row.Gamut_Attribute_Name) == True:
                df.at[row.Index, 'Matching'] = 'Grainger only'
        elif process.isBlank(row.Grainger_Attribute_Name) == True:
            if process.isBlank(row.Gamut_Attribute_Name) == False:
                df.at[row.Index, 'Matching'] = 'Gamut only'

    return df