class_docstr: Produce a simple ASCII, CSV, HTML, or LaTeX table from a
  *rectangular* (2d!) array of data, not necessarily numerical.
  Directly supports at most one header row,
  which should be the length of data[0].
  Directly supports at most one stubs column,
  which must be the length of data.
  (But see `insert_stubs` method.)
  See globals `default_txt_fmt`, `default_csv_fmt`, `default_html_fmt`,
  and `default_latex_fmt` for formatting options.
  
  Sample uses::
  
      mydata = [[11,12],[21,22]]  # data MUST be 2-dimensional
      myheaders = [ "Column 1", "Column 2" ]
      mystubs = [ "Row 1", "Row 2" ]
      tbl = text.SimpleTable(mydata, myheaders, mystubs, title="Title")
      print( tbl )
      print( tbl.as_html() )
      # set column specific data formatting
      tbl = text.SimpleTable(mydata, myheaders, mystubs,
          data_fmts=["%3.2f","%d"])
      print( tbl.as_csv() )
      with open('c:/temp/temp.tex','w') as fh:
          fh.write( tbl.as_latex_tabular() )
class_docstr_tok: ["Produce","a","simple","ASCII",",","CSV",",","HTML",",","or","LaTeX","table","from","a","*","rectangular","*","(","2d","!",")","array","of","data",",","not","necessarily","numerical",".","Directly","supports","at","most","one","header","row",",","which","should","be","the","length","of","data","[","0","]",".","Directly","supports","at","most","one","stubs","column",",","which","must","be","the","length","of","data",".","(","But","see","`","insert_stubs","`","method",".",")","See","globals","`","default_txt_fmt","`",",","`","default_csv_fmt","`",",","`","default_html_fmt","`",",","and","`","default_latex_fmt","`","for","formatting","options",".","Sample","uses",":",":","mydata","=","[","[","11,12","]",",","[","21,22","]","]","#","data","MUST","be","2-dimensional","myheaders","=","[","``","Column","1","''",",","``","Column","2","''","]","mystubs","=","[","``","Row","1","''",",","``","Row","2","''","]","tbl","=","text.SimpleTable","(","mydata",",","myheaders",",","mystubs",",","title=","''","Title","''",")","print","(","tbl",")","print","(","tbl.as_html","(",")",")","#","set","column","specific","data","formatting","tbl","=","text.SimpleTable","(","mydata",",","myheaders",",","mystubs",",","data_fmts=","[","``","%","3.2f","''",",","''","%","d","''","]",")","print","(","tbl.as_csv","(",")",")","with","open","(","'","c",":","\/temp\/temp.tex","'",",","'","w","'",")","as","fh",":","fh.write","(","tbl.as_latex_tabular","(",")",")"]
docstr: Parameters
  ----------
  data : list of lists or 2d array (not matrix!)
      R rows by K columns of table elements
  headers : list (or tuple) of str
      sequence of K strings, one per header
  stubs : list (or tuple) of str
      sequence of R strings, one per stub
  title : str
      title of the table
  datatypes : list of int
      indexes to `data_fmts`
  txt_fmt : dict
      text formatting options
  ltx_fmt : dict
      latex formatting options
  csv_fmt : dict
      csv formatting options
  hmtl_fmt : dict
      hmtl formatting options
  celltype : class
      the cell class for the table (default: Cell)
  rowtype : class
      the row class for the table (default: Row)
  fmt_dict : dict
      general formatting options
docstr_tok: ["Parameters","--","--","--","--","--","data",":","list","of","lists","or","2d","array","(","not","matrix","!",")","R","rows","by","K","columns","of","table","elements","headers",":","list","(","or","tuple",")","of","str","sequence","of","K","strings",",","one","per","header","stubs",":","list","(","or","tuple",")","of","str","sequence","of","R","strings",",","one","per","stub","title",":","str","title","of","the","table","datatypes",":","list","of","int","indexes","to","`","data_fmts","`","txt_fmt",":","dict","text","formatting","options","ltx_fmt",":","dict","latex","formatting","options","csv_fmt",":","dict","csv","formatting","options","hmtl_fmt",":","dict","hmtl","formatting","options","celltype",":","class","the","cell","class","for","the","table","(","default",":","Cell",")","rowtype",":","class","the","row","class","for","the","table","(","default",":","Row",")","fmt_dict",":","dict","general","formatting","options"]
code: def __init__(
      self,
      data,
      headers=None,
      stubs=None,
      title="",
      datatypes=None,
      csv_fmt=None,
      txt_fmt=None,
      ltx_fmt=None,
      html_fmt=None,
      celltype=None,
      rowtype=None,
      **fmt_dict,
  ):
      """
      Parameters
      ----------
      data : list of lists or 2d array (not matrix!)
          R rows by K columns of table elements
      headers : list (or tuple) of str
          sequence of K strings, one per header
      stubs : list (or tuple) of str
          sequence of R strings, one per stub
      title : str
          title of the table
      datatypes : list of int
          indexes to `data_fmts`
      txt_fmt : dict
          text formatting options
      ltx_fmt : dict
          latex formatting options
      csv_fmt : dict
          csv formatting options
      hmtl_fmt : dict
          hmtl formatting options
      celltype : class
          the cell class for the table (default: Cell)
      rowtype : class
          the row class for the table (default: Row)
      fmt_dict : dict
          general formatting options
      """
      self.title = title
      self._datatypes = datatypes
      if self._datatypes is None:
          self._datatypes = (
              [] if len(data) == 0 else lrange(len(data[0]))
          )
      # start with default formatting
      self._txt_fmt = default_txt_fmt.copy()
      self._latex_fmt = default_latex_fmt.copy()
      self._csv_fmt = default_csv_fmt.copy()
      self._html_fmt = default_html_fmt.copy()
      # substitute any general user specified formatting
      # :note: these will be overridden by output specific arguments
      self._csv_fmt.update(fmt_dict)
      self._txt_fmt.update(fmt_dict)
      self._latex_fmt.update(fmt_dict)
      self._html_fmt.update(fmt_dict)
      # substitute any output-type specific formatting
      self._csv_fmt.update(csv_fmt or dict())
      self._txt_fmt.update(txt_fmt or dict())
      self._latex_fmt.update(ltx_fmt or dict())
      self._html_fmt.update(html_fmt or dict())
      self.output_formats = dict(
          txt=self._txt_fmt,
          csv=self._csv_fmt,
          html=self._html_fmt,
          latex=self._latex_fmt,
      )
      self._Cell = celltype or Cell
      self._Row = rowtype or Row
      rows = self._data2rows(data)  # a list of Row instances
      list.__init__(self, rows)
      self._add_headers_stubs(headers, stubs)
      self._colwidths = dict()
  
imports: from statsmodels.compat.python import lmap, lrange
  from itertools import cycle, zip_longest
  import csv
label_desc: Use image node_id 1 to create a new SimpleTable object from inherited base classes: list with example: obj = SimpleTable(data, headers, stubs, title, datatypes, csv_fmt, txt_fmt, ltx_fmt, html_fmt, celltype, rowtype)