Converts each multiline string in a table to single line.

    Parameters
    ----------
    table : list of list of str
        A list of rows containing strings

    Returns
    -------
    table : list of lists of str
774559
def multis_2_mono(table):
    
    for row in range(len(table)):
        for column in range(len(table[row])):
            table[row][column] = table[row][column].replace('\n', ' ')

    return table
98227
def _process_table_cells(self, table):
        

        rows = []

        for i, tr in enumerate(table.find_all('tr')):
            row = []

            for c in tr.contents:
                cell_type = getattr(c, 'name', None)

                if cell_type not in ('td', 'th'):
                    continue

                rowspan = int(c.attrs.get('rowspan', 1))
                colspan = int(c.attrs.get('colspan', 1))
                contents = self._process_children(c).strip()

                if cell_type == 'th' and i > 0:
                    contents = self._inline('**', contents)

                row.append(Cell(cell_type, rowspan, colspan, contents))

            rows.append(row)

        return rows
877706
def format_table(columns, rows):
    
    rows = [tuple(str(i) for i in r) for r in rows]
    columns = tuple(str(i).upper() for i in columns)
    if rows:
        widths = tuple(max(max(map(len, x)), len(c))
                       for x, c in zip(zip(*rows), columns))
    else:
        widths = tuple(map(len, columns))
    row_template = ('    '.join('%%-%ds' for _ in columns)) % widths
    header = (row_template % tuple(columns)).strip()
    if rows:
        data = '\n'.join((row_template % r).strip() for r in rows)
        return '\n'.join([header, data])
    else:
        return header
877248
def dump_table(data: List[dict], fieldnames: Sequence[str]) -> str:
    

    def min3(num: int) -> int:
        return 3 if num < 4 else num

    width_by_col: Dict[str, int] = {
        f: min3(max([string_width(str(d.get(f))) for d in data] + [string_width(f)])) for f in fieldnames
    }

    def fill_spaces(word: str, width: int, center=False):
        """ aaa, 4 => ' aaa  ' """
        to_fills: int = width - string_width(word)
        return f" {' ' * floor(to_fills / 2)}{word}{' ' * ceil(to_fills / 2)} " if center \
            else f" {word}{' ' * to_fills} "

    def to_record(r: dict) -> str:
        return f"|{'|'.join([fill_spaces(str(r.get(f)), width_by_col.get(f)) for f in fieldnames])}|"

    return f"""
|{'|'.join([fill_spaces(x, width_by_col.get(x), center=True) for x in fieldnames])}|
|{'|'.join([fill_spaces(width_by_col.get(x) * "-", width_by_col.get(x)) for x in fieldnames])}|
{os.linesep.join([to_record(x) for x in data])}
""".lstrip()
270983
def reduce_multiline(string):
    
    string = str(string)
    return " ".join([item.strip()
                     for item in string.split("\n")
                     if item.strip()])
685706
def _GetTable(self):
    
    result = []
    # Avoid the global lookup cost on each iteration.
    lstr = str
    for row in self._table:
      result.append(
          '%s\n' %
          self.separator.join(lstr(v) for v in row))

    return ''.join(result)
735066
def _get_table_as_string(self):
        """"""
        tablelist = []
        tablelist.append("!%s_table_begin" % self.geotype.lower())
        tablelist.append("\t".join(self.table.columns))
        for idx, row in self.table.iterrows():
            tablelist.append("\t".join(map(str, row)))
        tablelist.append("!%s_table_end" % self.geotype.lower())
        return "\n".join(tablelist)
138730
def do_rmall(self, line):
        ""
        args = self.getargs(line)
        if args and args[-1] == "yes":
            args.pop()

            if not args:
                args = [self.table.name]

            while args:
                table = self.conn.get_table(args.pop(0))
                print "from table " + table.name

                for item in table.scan(attributes_to_get=[], request_limit=10):
                    print "  removing %s" % item
                    item.delete()
        else:
            print "ok, never mind..."
439903
def _format_table(fmt, headers, rows, colwidths, colaligns, is_multiline):
    """"""
    lines = []
    hidden = fmt.with_header_hide if (headers and fmt.with_header_hide) else []
    pad = fmt.padding
    headerrow = fmt.headerrow

    padded_widths = [(w + 2 * pad) for w in colwidths]
    if is_multiline:
        pad_row = lambda row, _: row  # do it later, in _append_multiline_row
        append_row = partial(_append_multiline_row, pad=pad)
    else:
        pad_row = _pad_row
        append_row = _append_basic_row

    padded_headers = pad_row(headers, pad)
    padded_rows = [pad_row(row, pad) for row in rows]

    if fmt.lineabove and "lineabove" not in hidden:
        _append_line(lines, padded_widths, colaligns, fmt.lineabove)

    if padded_headers:
        append_row(lines, padded_headers, padded_widths, colaligns, headerrow)
        if fmt.linebelowheader and "linebelowheader" not in hidden:
            _append_line(lines, padded_widths, colaligns, fmt.linebelowheader)

    if padded_rows and fmt.linebetweenrows and "linebetweenrows" not in hidden:
        # initial rows with a line below
        for row in padded_rows[:-1]:
            append_row(lines, row, padded_widths, colaligns, fmt.datarow)
            _append_line(lines, padded_widths, colaligns, fmt.linebetweenrows)
        # the last row without a line below
        append_row(lines, padded_rows[-1], padded_widths, colaligns, fmt.datarow)
    else:
        for row in padded_rows:
            append_row(lines, row, padded_widths, colaligns, fmt.datarow)

    if fmt.linebelow and "linebelow" not in hidden:
        _append_line(lines, padded_widths, colaligns, fmt.linebelow)

    return "\n".join(lines)
934324
def text(self):
        
        text = []
        rows = self.rowCount()
        cols = self.columnCount()

        # handle empty table case
        if rows == 2 and cols == 2:
            item = self.item(0, 0)
            if item is None:
                return ''

        for r in range(rows - 1):
            for c in range(cols - 1):
                item = self.item(r, c)
                if item is not None:
                    value = item.text()
                else:
                    value = '0'

                if not value.strip():
                    value = '0'

                text.append(' ')
                text.append(value)
            text.append(ROW_SEPARATOR)

        return ''.join(text[:-1])
519980
def print_table(table):
    
    table = [[str(cell) for cell in row] for row in table]
    column_widths = [len(cell) for cell in table[0]]
    for row in table:
        for x, cell in enumerate(row):
            column_widths[x] = max(column_widths[x], len(cell))

    formatters = []
    for width in column_widths:
        formatters.append('{:>' + str(width) + '}')
    formatter = '  '.join(formatters)
    for row in table:
        print(formatter.format(*row))
42226
def table(*columns, &_block)
      rows = []
      yield(rows)

      @io << tag(:table, class: 'rla-report-table', cellspacing: 0) do |content|
        if table_has_header?(columns)
          content << tag(:tr) do
            columns.map { |col| tag(:th, col[:title]) }.join("\n")
          end
        end

        odd = false
        rows.each do |row|
          odd = !odd
          content << tag(:tr) do
            if odd
              row.map { |cell| tag(:td, cell, class: 'alt') }.join("\n")
            else
              row.map { |cell| tag(:td, cell) }.join("\n")
            end
          end
        end
      end
    end
457456
def read_table(fstream):
    
    pos = fstream.tell()
    line = fstream.readline().strip()
    fragments = line.split(",")
    fragments = [x for x in fragments if x is not None]
    partition = dict()
    if not len(fragments) >= 4:
        return None

    partition["table"] = fragments[0]
    partition["group"] = fragments[1]
    partition["set"] = fragments[2]
    partition["num_lines"] = fragments[3]

    struct = None
    if partition is not None and partition["table"] == "TABLE":
        num_lines = int(partition["num_lines"].strip())
        struct = {}
        header = fetch_cols(fstream)

        struct.update({header[0]: header[1:]})
        for _ in range(num_lines):
            cols = fetch_cols(fstream)
            struct.update({cols[0]: cols[1:]})
    else:
        fstream.seek(pos)

    return struct
975723
def parse_string_table(self, tables):
        
        self.info("String table: %s" % (tables.tables, ))

        for table in tables.tables:
            if table.table_name == "userinfo":
                for item in table.items:
                    if len(item.data) > 0:
                        if len(item.data) == 140:
                            p = PlayerInfo()
                            ctypes.memmove(ctypes.addressof(p), item.data, 140)
                            p.str = item.str
                            self.run_hooks(p)
            if table.table_name == "CombatLogNames":
                self.combat_log_names = dict(enumerate(
                    (item.str for item in table.items)))
1329015
def __dumptable(self, table):
        
        for x in table.table.keys():
            sys.stdout.write("{0}\t<--- {1} {2}".format(x, table[x], type(table[x])))
            if isinstance(table[x], ID):
                sys.stdout(" {0}".format(table[x].value)),
            sys.stdout.write("\n")
59032
def parse_tablature(lines):
    '''  '''
    lines = [parse_line(l) for l in lines]
    return Tablature(lines=lines)
268091
def do_ls(self, table=None):
        
        if table is None:
            fields = OrderedDict(
                [
                    ("Name", "name"),
                    ("Status", "status"),
                    ("Read", "total_read_throughput"),
                    ("Write", "total_write_throughput"),
                ]
            )
            tables = self.engine.describe_all()
            # Calculate max width of all items for each column
            sizes = [
                1 + max([len(str(getattr(t, f))) for t in tables] + [len(title)])
                for title, f in iteritems(fields)
            ]
            # Print the header
            for size, title in zip(sizes, fields):
                print(title.ljust(size), end="")
            print()
            # Print each table row
            for row_table in tables:
                for size, field in zip(sizes, fields.values()):
                    print(str(getattr(row_table, field)).ljust(size), end="")
                print()
        else:
            print(self.engine.describe(table, refresh=True, metrics=True).pformat())