Return a dictionary list formatted as a HTML table.

    Args:
      data: a list of dictionaries, one per row.
      headers: the keys in the dictionary to use as table columns, in order.
343287
def render_table(data, headers=None):
    
    builder = HtmlBuilder()
    builder._render_objects(data, headers, datatype='dict')
    return builder._to_html()
779759
def to_dict(self):
        
        list_data = []
        for key, value in list(self.data.items()):
            row = list(key)
            row.append(value)
            list_data.append(row)
        return {
            'groups': self.groups,
            'data': list_data
        }
550894
def tabulate(collection, headers, datetime_fmt='%Y-%m-%d %H:%M:%S', **kwargs):
    """"""
    if isinstance(headers, dict):
        attrs = headers.keys()
        # if mapping is not specified keep original
        names = [
            key if value is None else value for key, value in headers.items()
        ]
    else:
        attrs = names = headers
    table = [(
        format_cell(cell, datetime_fmt=datetime_fmt)
        for cell in attrgetter(*attrs)(c)
    ) for c in collection]
    return tblte(table, headers=[h.upper() for h in names], **kwargs)
1136929
def _store_header(self):
        
        key, value = None, None
        headers = []
        header_line = yield
        while header_line is not None:
            if not header_line.startswith((b' ', b'\t')):
                if key:
                    headers.append((key, value))
                key, value = self.split_header_key_value(header_line)
                key = key.upper()
            else:
                next_val = header_line.strip().decode()
                if isinstance(value, list):
                    value.append(next_val)
                else:
                    value = [value, next_val]
            header_line = yield

        if key is not None:
            headers.append((key, value))

        yield dict(headers)
691004
def headers(self, serialize_cell=None):
    """"""
    if serialize_cell is None:
      serialize_cell = self.get_cell_value
    return [serialize_cell(cell) for cell in self.rows[0]]
1276962
def write_table(page, headers, data, cl=''):

    

    page.table(class_=cl)

    # list
    if cl=='list':
        for i in range(len(headers)):

            page.tr()
            page.th()
            page.add('%s' % headers[i])
            page.th.close()
            page.td()
            page.add('%s' % data[i])
            page.td.close()
            page.tr.close()

    else:
        page.tr()
        for n in headers:
            page.th()
            page.add('%s' % n)
            page.th.close()
        page.tr.close()

        if data and not re.search('list',str(type(data[0]))):
            data = [data]

        for row in data:
            page.tr()
            for item in row:
                page.td()
                page.add('%s' % item)
                page.td.close()
            page.tr.close()

    page.table.close()

    return page
495595
def headers(self):
        
        if self._headers is None:
            query = CellQuery()
            query.max_row = '1'
            feed = self._service.GetCellsFeed(self._ss.id, self.id,
                                              query=query)
            self._headers = feed.entry
        return [normalize_header(h.cell.text) for h in self._headers]
1217782
def import_from_dicts(data, samples=None, *args, **kwargs):
    

    data = iter(data)

    cached_rows, headers = [], []
    for index, row in enumerate(data, start=1):
        cached_rows.append(row)

        for key in row.keys():
            if key not in headers:
                headers.append(key)

        if samples and index == samples:
            break

    data_rows = (
        [row.get(header, None) for header in headers]
        for row in chain(cached_rows, data)
    )

    kwargs["samples"] = samples
    meta = {"imported_from": "dicts"}
    return create_table(chain([headers], data_rows), meta=meta, *args, **kwargs)
881266
function _getHeaderAligns(tableData) {
  const [headRowData] = tableData;

  return headRowData.map(cellData => {
    let align;

    if (util.isExisty(cellData.colMergeWith)) {
      ({align} = headRowData[cellData.colMergeWith]);
    } else {
      ({align} = cellData);
    }

    return align;
  });
}
897999
def _cdata_header(self, colsep="|"):
        
        fields = self.fields
        header_lines = []
        line = ""
        for fieldName in self.field_names:
            width = int(fields[fieldName]['attr']['width'])
            line += self._entry(fieldName, width, colsep)
        header_lines.append(line)

        line = ""
        for fieldName in self.field_names:
            width = int(fields[fieldName]['attr']['width'])
            line += self._entry(fields[fieldName]['attr']['format'], width=width, colsep=colsep)
        header_lines.append(line)

        line = ""
        for fieldName in self.field_names:
            width = int(fields[fieldName]['attr']['width'])
            (l, m) = divmod(width, 10)
            guide = ""
            for i in range(l):
                guide += "".join(map(str, range(10)))
            guide += "".join(map(str, range(m)))
            line += self._entry(guide, width=width, colsep=colsep)
        header_lines.append(line)

        line = ""
        for fieldName in self.field_names:
            width = int(fields[fieldName]['attr']['width'])
            guide = "-" * width
            line += self._entry(guide, width=width, colsep=colsep)
        header_lines.append(line)

        return header_lines
53108
def translate_table(data):
    
    headers = sorted(data.get("Headers", []))
    table = '\\FloatBarrier \n \\section{$NAME} \n'.replace('$NAME', data.get("Title", "table"))
    table += '\\begin{table}[!ht] \n \\begin{center}'

    # Set the number of columns
    n_cols = "c"*(len(headers)+1)
    table += '\n \\begin{tabular}{$NCOLS} \n'.replace("$NCOLS", n_cols)

    # Put in the headers
    for header in headers:
        table += ' $HEADER &'.replace('$HEADER', header).replace('%', '\%')
    table = table[:-1] + ' \\\\ \n \hline \n'

    # Put in the data
    for header in headers:
        table += ' $VAL &'.replace("$VAL", str(data["Data"][header]))
    table = table[:-1] + ' \\\\ \n \hline'
    table += '\n \end{tabular} \n \end{center} \n \end{table}\n'
    return table
821760
def _unpack_headers(self, headers):
        
        return dict((k,v[0]) for (k,v) in headers.getAllRawHeaders())
647951
def _read_as_dict(self):
        
        data = list()
        for row in self._rows:
            row_data = OrderedDict()
            for i, header in enumerate(self.headers):
                row_data[header.cget('text')] = row[i].get()

            data.append(row_data)

        return data
560734
def to_even_columns(data, headers=None):
    
    result = ''
    col_width = max(len(word) for row in data for word in row) + 2  # padding
    if headers:
        header_width = max(len(word) for row in headers for word in row) + 2
        if header_width > col_width:
            col_width = header_width

        result += "".join(word.ljust(col_width) for word in headers) + "\n"
        result += '-' * col_width * len(headers) + "\n"

    for row in data:
        result += "".join(word.ljust(col_width) for word in row) + "\n"
    return result
431053
def _headers(self, headers_dict):
        
        return Headers(dict((k,[v]) for (k,v) in headers_dict.items()))
1337162
def _createDataStructure(self, content):
        
        aux = {}
        aux["headers"] = {}
        aux["content"] = ""
        for i, line in enumerate(content.splitlines()):
            if i == 0:
                aux["procotol"] = line.split()[0]
                aux["code"] = line.split()[1]
            elif line != "":
                header =  line.split(": ")[0]
                aux["headers"][header] = line[line.find(": ")+2:]
            else:
                aux["content"] += self._rebuildHTMLContent(content.splitlines()[i+1:])
                
                # TO-DO: Perform additional processing of the HTML
                
                break  
        return aux
507306
def create_dicts(data):
    
    chars = set()
    for sample in data:
        chars.update(set(sample))
    char_indices = dict((c, i) for i, c in enumerate(chars))
    indices_char = dict((i, c) for i, c in enumerate(chars))
    return char_indices, indices_char