def tabledump(filename, datafile=None, cdfile=None, hfile=None, ext=1,
              clobber=False):

    # allow file object to already be opened in any of the valid modes
    # and leave the file in the same state (opened or closed) as when
    # the function was called

    mode, closed = _get_file_mode(filename, default='readonly')
    f = fitsopen(filename, mode=mode)

    # Create the default data file name if one was not provided

    if not datafile:
        # TODO: Really need to provide a better way to access the name of any
        # files underlying an HDU
        root, tail = os.path.splitext(f._HDUList__file.name)
        datafile = root + '_' + repr(ext) + '.txt'

    # Dump the data from the HDU to the files
    f[ext].dump(datafile, cdfile, hfile, clobber)

    if closed:
        f.close()
Dump a table HDU to a file in ASCII format.  The table may be
dataset/ETHPy150Open spacetelescope/PyFITS/pyfits/convenience.py/tabledump