<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def read_table(filename, sheetname, index_col=None):
 """ Return the contents of an Excel table as a pandas DataFrame. Parameters filename : str Name of the Excel file to read. sheetname : str or int Name or index of the sheet inside the Excel file to read. index_col : str, optional Column name or index to be used as row labels of the DataFrame. If None, default index will be used. Returns ------- table : DataFrame A DataFrame containing the data in the specified Excel table. If `index_col` is not None, rows in which their `index_col` field is empty will not be present in `table`. Raises ------ ValueError If `index_col` is specified and two rows contain the same `index_col` field. """

    # Catch sheetname as list or None
    if sheetname is None or \
            (hasattr(sheetname, '__iter__') \
            and not isinstance(sheetname, six.string_types)):
        raise TypeError("sheetname should specify a single sheet")

    # Load excel table using pandas
    # Parameter specifying sheet name is slightly different depending on pandas'
    # version.
    if packaging.version.parse(pd.__version__) \
                < packaging.version.parse('0.21'):
        table = pd.read_excel(filename,
                              sheetname=sheetname,
                              index_col=index_col)
    else:
        table = pd.read_excel(filename,
                              sheet_name=sheetname,
                              index_col=index_col)
    # Eliminate rows whose index are null
    if index_col is not None:
        table = table[pd.notnull(table.index)]
    # Check for duplicated rows
    if table.index.has_duplicates:
        raise ValueError("sheet {} on file {} contains duplicated values "
                         "for column {}".format(sheetname, filename, index_col))

    return table