def check_columns(filename):
    """
    Check the columns in an input file for numerical values.

    This routine takes as input a file name.  It reads in the lines
    from the file and determines the number of columns plus the index
    values of the numerical columns.  It is assumed that the first
    column without '#', '|' or '\' is the template for all the lines, so
    only the first "data" line is split up and checked for
    numerical values in the columns.  The indices are then
    used with numpy.loadtxt.

    Parameters
    ----------

        filename :   the name of the file with regular columns to check

    Returns
    -------
        inds :       a list of the numerical columns in the file

        ncols :      the total number of columns in the file

    If an error occurs, inds and ncols are returned as None.

    """
    try:
        infile = open(filename, 'r')
        lines = infile.readlines()
        infile.close()
        ncols = 0
        inds = []
        for line in lines:
            if ncols == 0:
                line = line.strip('\n')
                if ('#' in line[0:1]) | ('\\' in line[0:1]) | \
                   ('|' in line[0:1]) | ('x_or_RA' in line):
                    pass
                else:
                    values = line.split('#')
                    subline = values[0]
                    values = subline.split('|')
                    subline = values[0]
                    values = subline.split('\\')
                    subline = values[0]
                    values = subline.split()
                    ncols = len(values)
                    for loop in range(ncols):
                        try:
                            x = float(values[loop])
                            inds.append(loop)
                        except:
                            pass
        return inds, ncols
    except Exception:
        return None, None