def tabular2html(fname=None, X=None, fin=None, title=None, printheader=False, <EOL>split=True, usecss=None, writecss=None, SERVERNAME=None, <EOL>SERVER_FROM_CURDIR='<STR_LIT>', ROWS_PER_PAGE=<NUM_LIT:1000>, <EOL>returnstring = False, **kwargs):
<EOL>assert returnstring or fname.endswith( '<STR_LIT>' ), '<STR_LIT>'<EOL>if X is None:<EOL><INDENT>if fin is not None:<EOL><INDENT>if fin.lstrip('<STR_LIT:/>').endswith('<STR_LIT>'):<EOL><INDENT>kwargs['<STR_LIT>'] = fin<EOL><DEDENT>elif fin.endswith('<STR_LIT>') or fin.endswith('<STR_LIT>'):<EOL><INDENT>kwargs['<STR_LIT>'] = fin<EOL><DEDENT>elif fin.endswith(('<STR_LIT>','<STR_LIT>')):<EOL><INDENT>kwargs['<STR_LIT>'] = fin<EOL><DEDENT>else:<EOL><INDENT>assert False, ('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' <EOL>'<STR_LIT>'<EOL>'<STR_LIT>' <EOL>'<STR_LIT>'<EOL>'<STR_LIT>' <EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>assert any([l in kwargs.keys() and kwargs[l] != None <EOL>for l in ['<STR_LIT>','<STR_LIT>','<STR_LIT>']]),('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>X = tb.tabarray(**kwargs)<EOL><DEDENT>names = X.dtype.names<EOL>try:<EOL><INDENT>RowColors = X['<STR_LIT>']<EOL><DEDENT>except:<EOL><INDENT>if '<STR_LIT>' in names:<EOL><INDENT>cspot = names.index('<STR_LIT>')<EOL>RowColors = [r[cspot] for r in X]<EOL><DEDENT>else:<EOL><INDENT>RowColors = ['<STR_LIT>'] * len(X)<EOL><DEDENT><DEDENT>try:<EOL><INDENT>coloring = X.coloring<EOL><DEDENT>except:<EOL><INDENT>coloring = {}<EOL><DEDENT>Num_Records = len(X)<EOL>Num_Cols = len(names)<EOL>ColorStyles = CSSColoring(names, coloring)<EOL>HdrNts = HeaderNotations(names, coloring)<EOL>if usecss != None:<EOL><INDENT>if isinstance(usecss, str):<EOL><INDENT>cssfile = usecss<EOL>CSSLINK = ('<STR_LIT>' + '<STR_LIT:/>' + <EOL>cssfile[len(SERVER_FROM_CURDIR):] + '<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>assert usecss == False<EOL>CSSLINK = '<STR_LIT>'<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if writecss == False or returnstring:<EOL><INDENT>CSSLINK = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>if not isinstance(writecss,str):<EOL><INDENT>cssfile = fname[:-<NUM_LIT:5>] + '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>cssfile = writecss<EOL><DEDENT>WriteOutCSS(ColorStyles[<NUM_LIT:1>],cssfile)<EOL>CSSLINK = ('<STR_LIT>' + '<STR_LIT:/>'  + <EOL>cssfile[len(SERVER_FROM_CURDIR):] + '<STR_LIT>')<EOL><DEDENT><DEDENT>if returnstring:<EOL><INDENT>split = False<EOL><DEDENT>if not split or ROWS_PER_PAGE == '<STR_LIT:all>':<EOL><INDENT>ROWS_PER_PAGE = Num_Records + <NUM_LIT:1><EOL><DEDENT>numSections = int(Num_Records / ROWS_PER_PAGE) + <NUM_LIT:1>   <EOL>section2file = (lambda sectionNum: fname if sectionNum == <NUM_LIT:0> <EOL>else splitext(fname)[<NUM_LIT:0>] + str(sectionNum) + splitext(fname)[<NUM_LIT:1>])<EOL>if title is None:<EOL><INDENT>if not fin is None:<EOL><INDENT>title = fin<EOL><DEDENT>else:<EOL><INDENT>title = '<STR_LIT>'<EOL><DEDENT><DEDENT>for section in range(numSections):<EOL><INDENT>sectionfname = section2file(section)<EOL>fromRow = section * ROWS_PER_PAGE  <EOL>toRow = min( fromRow + ROWS_PER_PAGE, Num_Records)  <EOL>if printheader and not returnstring:<EOL><INDENT>prefix = '<STR_LIT:/>' + DirName(fname[len(SERVER_FROM_CURDIR):]) + '<STR_LIT:/>'<EOL><DEDENT>else:<EOL><INDENT>prefix = '<STR_LIT>'<EOL><DEDENT>if not returnstring:<EOL><INDENT>f = open(sectionfname,'<STR_LIT:w>')<EOL><DEDENT>else:<EOL><INDENT>f = tempfile.TemporaryFile('<STR_LIT>')<EOL><DEDENT>if not returnstring:<EOL><INDENT>f.write('<STR_LIT>'<EOL>'<STR_LIT>' + <EOL>title + '<STR_LIT>' + CSSLINK + '<STR_LIT>' )<EOL><DEDENT>if printheader:<EOL><INDENT>f.write('<STR_LIT>' + str(section + <NUM_LIT:1>) + '<STR_LIT>' + <EOL>str(numSections) + '<STR_LIT>' + str(fromRow + <NUM_LIT:1>) + <EOL>'<STR_LIT>' + str(toRow) + '<STR_LIT>' + title + '<STR_LIT>')<EOL>f.write('<STR_LIT>')<EOL>if section > <NUM_LIT:0>:<EOL><INDENT>f.write('<STR_LIT>' + prefix + <EOL>basename(section2file(section - <NUM_LIT:1>)) + '<STR_LIT>')<EOL><DEDENT>if section < numSections - <NUM_LIT:1>:<EOL><INDENT>f.write('<STR_LIT>' + prefix + <EOL>basename(section2file(section + <NUM_LIT:1>)) + '<STR_LIT>')<EOL><DEDENT>for page in range(numSections):<EOL><INDENT>f.write(('<STR_LIT>' + prefix + <EOL>basename(section2file(page)) + '<STR_LIT>' + str(page + <NUM_LIT:1>) + <EOL>'<STR_LIT>') if page != section else '<STR_LIT:U+0020>' + str(page + <NUM_LIT:1>))<EOL><DEDENT>f.write( '<STR_LIT>' )<EOL><DEDENT>f.write('<STR_LIT>')<EOL>f.write('<STR_LIT>' + str(Num_Cols) + '<STR_LIT>')<EOL>f.write('<STR_LIT>')<EOL>if len(HdrNts) > <NUM_LIT:0>:<EOL><INDENT>for h in HdrNts:<EOL><INDENT>f.write(h + '<STR_LIT:\n>')<EOL><DEDENT><DEDENT>f.write('<STR_LIT>')<EOL>for name in names:<EOL><INDENT>f.write('<STR_LIT>' + ColorStyles[<NUM_LIT:0>][name] + '<STR_LIT>' + <EOL>cgi.escape(name) + '<STR_LIT>')<EOL><DEDENT>f.write('<STR_LIT>')<EOL>f.write('<STR_LIT>')<EOL>f.write( '<STR_LIT>' )<EOL>if (len(names) > <NUM_LIT:1>) or (fin != None and fin.endswith('<STR_LIT>')):<EOL><INDENT>for row in range( fromRow, toRow ):<EOL><INDENT>colorst = ('<STR_LIT>' + RowColors[row] + <EOL>'<STR_LIT>' if  RowColors[row] != '<STR_LIT>' else '<STR_LIT>')<EOL>f.write('<STR_LIT>')<EOL>for (i, val) in enumerate(X[ row ]):<EOL><INDENT>f.write('<STR_LIT>' + colorst + '<STR_LIT>' + <EOL>ColorStyles[<NUM_LIT:0>][names[i]] + '<STR_LIT>' + str(val).replace('<STR_LIT:\n>','<STR_LIT>') + <EOL>'<STR_LIT>')<EOL><DEDENT>f.write('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for row in range(fromRow, toRow):<EOL><INDENT>f.write('<STR_LIT>')<EOL>f.write('<STR_LIT>' + str(X[row]).replace('<STR_LIT:\n>','<STR_LIT>') + '<STR_LIT>')<EOL>f.write('<STR_LIT>')<EOL><DEDENT><DEDENT>f.write('<STR_LIT>')<EOL>f.write( '<STR_LIT>' )<EOL>if printheader:<EOL><INDENT>f.write('<STR_LIT>')<EOL>if section > <NUM_LIT:0>:<EOL><INDENT>f.write('<STR_LIT>' + prefix + <EOL>basename(section2file(section - <NUM_LIT:1>)) + '<STR_LIT>')<EOL><DEDENT>if section < numSections - <NUM_LIT:1>:<EOL><INDENT>f.write('<STR_LIT>' + prefix + <EOL>basename(section2file(section + <NUM_LIT:1>)) + '<STR_LIT>')<EOL><DEDENT>for page in range(numSections):<EOL><INDENT>f.write(('<STR_LIT>' + prefix + <EOL>basename(section2file(page)) + '<STR_LIT>' + <EOL>str(page + <NUM_LIT:1>) + '<STR_LIT>') if page != section <EOL>else '<STR_LIT:U+0020>' + str(page + <NUM_LIT:1>))<EOL><DEDENT>f.write('<STR_LIT>')<EOL><DEDENT>if not returnstring:<EOL><INDENT>f.write('<STR_LIT>')<EOL><DEDENT>if returnstring:<EOL><INDENT>f.seek(<NUM_LIT:0>)<EOL>s = f.read()<EOL>f.close()<EOL>return s<EOL><DEDENT>else:<EOL><INDENT>f.close()<EOL><DEDENT><DEDENT>
Creates an html representation of tabular data, either from a tabarray or 
an externa file (`including ``.hsv``, ``.csv``, ``.tsv``).  If no data is 
directly provided by passing a tabarray to `X`, then a tabarray is 
constructed using :func:`tabular.tabarray.tabarray.__new__`.

**Parameters**

        **fname** :  string

                Path to the "main" HTML file to be created.  This file path
                must end in ``.html``.

                Note that this function will create additional files (e.g. 
                a ``.css`` file and multiple linked ``.html`` files for 
                large datasets) linked to this HTML file, inside of the 
                directory containing `fname`.

        **X** :  tabarray

                If `X` is `None`, then one of `fin`, `array`, `records`,
                `columns`, `SV`, `HSV`, or `HSVlist` must not be `None`.

        **fin** :  string

                File path to to a source of tabular dat, which will be
                loaded using the tabarray constructor.  The load method
                will be inferred from the file extension and whether or not
                there is a headerkey in the first line of the file.

        **title** :  string

                Description to be used in the <title> tag of the created
                html file.

        **printheader** : boolean

                If `printheader = True`, will print out a "header" and 
                "footer" (both in the body of the HTML documents) on every 
                page.  The header contains information about the name of 
                the input file and the number of rows, as well what the 
                current page number is (if split between multiple 
                documents) and links to any other pages.  The footer 
                contains the same page number and links.

        **split** : boolean

                If `split = False`, will not split to multiple HTML pages, 
                regardless of value of `ROWS_PER_PAGE`.

        **usecss** : False or None or string

                If usecss is False, no link to a cssfile is included in the 
                page header, and no cssfile is written out.  If is a 
                string, that string is assumed to be a path and is linked 
                to as the CSS file.  If it is None, then consideration of 
                the `writecss` variable is made.

        **writecss** : boolean

                If `usecss` is not `None`, then if `writecss` is not 
                `False`:  the default css sheet is generated and written to 
                a file whose name is either generated by default (if 
                writecss is None) else given by writecss itself, and linked 
                to in the file header

        **SERVERNAME** :  string

                Server name.  For example, this could be the ServerName
                of a VirtualHost on your local machine, assuming that
                `fname` describes a path on the server.

        **SERVER_FROM_CURDIR** :  string

                Root path of server relative to the current directory.
                Assumed to be '../'.

        **ROWS_PER_PAGE** :  positive integer or 'all'

                This sets the number of records displayed per .html page
                (if the tabular file has more than ROWS_PER_PAGE rows,
                it will be split into multiple sections on several .html
                pages (default = 1000).

                If the value is 'all' then the page is not split (e.g. it 
                is as if split = False)

        **See also:**  the kwargs arguments must be valid keyword arguments 
        for :func:`tabular.tabarray.tabarray.__new__`, the tabarray 
        constructor, see documentation for descriptions.