def read_file_errorbar(filename, xcol=0, ycol=1, yerrcol=2):
    """
    Reads 3 columns of data from a file.

    Parameters
    ----------
    filename: str
        Filename of the file to read.
    xcol: int, optional
        Index of the olumn to be read as x data. Default 0.
    ycol: int, optional
        Index of the olumn to be read as y data. Default 1.
    yerrcol: int, optional
        Index of the olumn to be read as y error data. Default 2.

    Returns
    -------
    x: list(float)
        List with the x data values.
    y: list(float)
        List with the y data values.
    yerr: list(float)
        List with the y error data values.

    """

    f = open(filename, "Ur")
    x = []
    y = []
    yerr = []
    for l in f:
        if l.startswith("#"):
            pass
        elif l.startswith(r"@"):
            pass
        else:
            try:
                xval = float(l.split()[xcol])
                yval = float(l.split()[ycol])
                yerrval = float(l.split()[yerrcol])
                x.append(xval)
                y.append(yval)
                yerr.append(yerrval)
            except:
                pass
    return x, y, yerr