def cmd_table(self, tbl, file=None, fields=[]):
        """-4|-table [TABLENAME] optional[file=None] [fields=None]|\
the default tableStyle is no_wrap - use the 'set x y' command to change the style\n\
style choices:
\twrap_always
\twrap_onspace
\twrap_onspace_strict
\tno_wrap (value '')\n
\t the 2nd optional param is a path to a file where the table will be written
\t the 3rd optional param is a list of fields you want displayed\n"""
        table = None
        for mTbl in db.tables:
            if tbl in mTbl:
                if mTbl.startswith(tbl):
                    table = mTbl
                    break
        oTable = tableHelper()
        '''---
                tablestyle:
                        wrap_always
                            wrap_onspace
                                wrap_onspace_strict
                    or set set to "" for no wrapping
                                                                                    ---'''
        tableStyle = self.var_tableStyle
        filedNotFound = []
        table_fields = None
        if len(fields) == 0:
            table_fields = self.db[table].fields
        else:
            table_fields = fields

        for field in fields:
            if not field in self.db[table].fields:
                filedNotFound.append(field)
        if len(filedNotFound) == 0:
            rows = self.db(self.db[table].id > 0).select()
            rows_data = []
            for row in rows:
                rowdata = []
                for f in table_fields:
                    rowdata.append('{0}'.format(row[f]))
                rows_data.append(string.join(rowdata, ','))
            data = string.join(rows_data, '\n')
            dataTable = oTable.getTable_Wrap(data, tableStyle, table_fields)
            print('TABLE {0}\n{1}'.format(table, dataTable))
            if file is not None:
                try:
                    tail, head = os.path.split(file)
                    try:
                        os.makedirs(tail)
                    except:
                        'do nothing, folders exist'
                    oFile = open(file, 'w')
                    oFile.write('TABLE: {0}\n{1}'.format(table, dataTable))
                    oFile.close()
                    print('{0} has been created and populated with all available data from table {1}\n'.format(file, table))
                except Exception, err:
                    print("EXCEPTION: could not create table {0}\n{1}".format(
                        table, err))
        else:
            print('the following fields are not valid [{0}]'.format(
                string.join(filedNotFound, ',')))
dataset/ETHPy150Open uwdata/termite-visualizations/web2py/scripts/cpdb.py/console.cmd_table/original