def get_col_index(table, field_name):
    """ Searches the table for the field name in the table header, and returns
        the index of the column it occupies. Returns None if not found.
    """
    table_header = table.tr
    column_names = table_header.findAll('th')

    for i, col in enumerate(column_names):
        if field_name in col.text:
            return i
    return None