checkName uses a database to return either SMILES or IUPAC
    names of cations/anions.

    Default behavior is to return the SMILES encoding of an ion given
    the ion name as input.

    Parameters
    ------------------
    user_query : str
        string that will be used to query the database.

    Returns
    ------------------
    output: str
        either the name of the salt, cation, or anion; or SMILES of the
        salt, cation, or anion (SMILES for the salt are written as the
        cation and ion SMILES strings separated by a comma)

def check_name(user_query, index=False):
    """
    checkName uses a database to return either SMILES or IUPAC
    names of cations/anions.

    Default behavior is to return the SMILES encoding of an ion given
    the ion name as input.

    Parameters
    ------------------
    user_query : str
        string that will be used to query the database.

    Returns
    ------------------
    output: str
        either the name of the salt, cation, or anion; or SMILES of the
        salt, cation, or anion (SMILES for the salt are written as the
        cation and ion SMILES strings separated by a comma)
    """
    df_cation = load_data("cationInfo.csv")
    df_anion = load_data("anionInfo.csv")

    def _look_up_info_file(df):
        target_lookup = df.loc[(df == user_query).any(axis=1), :]
        input_type = df.loc[:, (df == user_query).any(axis=0)].columns.values
        column_index = df.columns.get_loc(input_type[0])
        row_index = df.loc[(df == user_query).any(axis=1), :].index.tolist()[0]
        return target_lookup, input_type, column_index, row_index

    try:
        target_lookup, input_type, column_index, row_index =\
            _look_up_info_file(df_cation)
    except BaseException:
        try:
            target_lookup, input_type, column_index, row_index = \
                _look_up_info_file(df_anion)
        except BaseException:
            print("query not found")
            return 0
    if column_index == 1:
        target = target_lookup.iloc[0][column_index - 1]
    else:
        target = target_lookup.iloc[0][column_index + 1]
    if index:
        return target, row_index
    else:
        return target