

def tohtml(table, source=None, encoding=None, errors='strict', caption=None, vrepr=text_type, lineterminator='\n', index_header=False, tr_style=None, td_styles=None, truncate=None):
    "\n    Write the table as HTML to a file. E.g.::\n\n        >>> import petl as etl\n        >>> table1 = [['foo', 'bar'],\n        ...           ['a', 1],\n        ...           ['b', 2],\n        ...           ['c', 2]]\n        >>> etl.tohtml(table1, 'example.html', caption='example table')\n        >>> print(open('example.html').read())\n        <table class='petl'>\n        <caption>example table</caption>\n        <thead>\n        <tr>\n        <th>foo</th>\n        <th>bar</th>\n        </tr>\n        </thead>\n        <tbody>\n        <tr>\n        <td>a</td>\n        <td style='text-align: right'>1</td>\n        </tr>\n        <tr>\n        <td>b</td>\n        <td style='text-align: right'>2</td>\n        </tr>\n        <tr>\n        <td>c</td>\n        <td style='text-align: right'>2</td>\n        </tr>\n        </tbody>\n        </table>\n\n    The `caption` keyword argument is used to provide a table caption\n    in the output HTML.\n\n    "
    source = write_source_from_arg(source)
    with hdr.open('wb') as buf:
        if PY2:
            codec = getcodec(encoding)
            f = codec.streamwriter(buf, errors=errors)
        else:
            f = io.TextIOWrapper(buf, encoding=encoding, errors=errors, newline='')
        try:
            it = iter(table)
            hdr = next(it)
            _write_begin(f, hdr, lineterminator, caption, index_header, truncate)
            if (tr_style and callable(tr_style)):
                it = (Record(row, hdr) for row in it)
            for row in it:
                _write_row(f, hdr, row, lineterminator, vrepr, tr_style, td_styles, truncate)
            _write_end(f, lineterminator)
            f.flush()
        finally:
            if (not PY2):
                f.detach()

dataset/ETHPy150Open alimanfoo/petl/petl/io/html.py tohtml/VarMisuse@60/443 `source`->`hdr`