Converts multirow cells to a list of lists and informs the number of lines of each row.

    Returns:
         tuple: new_data, row_heights
495964
def expand_multirow_data(data):
    

    num_cols = len(data[0]) # number of columns

    # calculates row heights
    row_heights = []
    for mlrow in data:
        row_height = 0
        for j, cell in enumerate(mlrow):
            row_height = max(row_height, 1 if not isinstance(cell, (list, tuple)) else len(cell))
        row_heights.append(row_height)
    num_lines = sum(row_heights) # line != row (rows are multiline)

    # rebuilds table data
    new_data = [[""]*num_cols for i in range(num_lines)]
    i0 = 0
    for row_height, mlrow in zip(row_heights, data):
        for j, cell in enumerate(mlrow):
            if not isinstance(cell, (list, tuple)):
                cell = [cell]

            for incr, x in enumerate(cell):
                new_data[i0+incr][j] = x

        i0 += row_height

    return new_data, row_heights
309672
public List<Row> getRowsCopy()
    {
        final List<Row> rows = new ArrayList<>(this.getRowsCount());

        for (Row cells : this)
        {
            rows.add(cells);
        }

        return rows;
    }
1139017
def parse_200_row(row: list) -> NmiDetails:
    
    return NmiDetails(row[1], row[2], row[3], row[4], row[5], row[6],
                         row[7], int(row[8]), parse_datetime(row[9]))
128381
def AddRow(self, values):
    
    if self._number_of_columns and len(values) != self._number_of_columns:
      raise ValueError('Number of values is out of bounds.')

    self._rows.append(values)

    if not self._number_of_columns:
      self._number_of_columns = len(values)
1187376
function (rows) {
		var row,
			rowsLength,
			col,
			colsLength,
			columns;

		if (rows) {
			columns = [];
			rowsLength = rows.length;
			for (row = 0; row < rowsLength; row++) {
				colsLength = rows[row].length;
				for (col = 0; col < colsLength; col++) {
					if (!columns[col]) {
						columns[col] = [];
					}
					columns[col][row] = rows[row][col];
				}
			}
		}
		return columns;
	}
76971
def resolve_rows(rows):
    
    merged_rows = []
    for row in rows:
        overlap = False
        for mrow in merged_rows:
            if any(axis_overlap(ax1, ax2) for ax1 in row
                   for ax2 in mrow):
                mrow += row
                overlap = True
                break
        if not overlap:
            merged_rows.append(row)
    if rows == merged_rows:
        return rows
    else:
        return resolve_rows(merged_rows)
1337119
def get_matrix(self):
        
        return np.array([ self.get_row_list(i) for i in range(self.row_count()) ])
1293402
def layout(self):
                
                ret = []
                for row in self.rows:
                        if len(row) > len(ret):
                                ret += [0] * (len(row) - len(ret))
                        for n, field in enumerate(row):
                                if field is self.empty_value:
                                        field = ''
                                ret[n] = max(ret[n], len(field))
                return ret
552084
def same_as(self, rows: List[Row], column: Column) -> List[Row]:
        
        cell_value = rows[0].values[column.name]
        return_list = []
        for table_row in self.table_data:
            if table_row.values[column.name] == cell_value:
                return_list.append(table_row)
        return return_list
215156
def _get_data_from_list_of_lists(source, fields='*', first_row=0, count=-1, schema=None):
  
  if schema is None:
    schema = google.datalab.bigquery.Schema.from_data(source)
  fields = get_field_list(fields, schema)
  gen = source[first_row:first_row + count] if count >= 0 else source
  cols = [schema.find(name) for name in fields]
  rows = [{'c': [{'v': row[i]} for i in cols]} for row in gen]
  return {'cols': _get_cols(fields, schema), 'rows': rows}, len(source)
536244
def transpose(self, rows):
        
        res = OrderedDict()
        for row, cols in rows.items():
            for col, cell in cols.items():
                if col not in res:
                    res[col] = OrderedDict()
                res[col][row] = cell
        return res
454409
def previous(self, rows: List[Row]) -> List[Row]:
        
        if not rows:
            return []
        input_row_index = self._get_row_index(rows[0])
        if input_row_index > 0:
            return [self.table_data[input_row_index - 1]]
        return []
737932
def to_table(data, headers)
      column_lengths = []
      gutter = 2
      table = ''

      # Figure out column widths based on longest string in each column (including the header string)
      headers.each { |header|
        width = data.map { |_| _[header] }.max_by(&:length).length

        width = header.length if width < header.length

        column_lengths << width
      }

      # format the length of a table cell string to make it as wide as the column (by adding extra spaces)
      format_row_entry = lambda { |entry, i|
        entry + (' ' * (column_lengths[i] - entry.length + gutter))
      }

      # Add headers
      headers.each_with_index { |header, i|
        table += format_row_entry.call(header, i)
      }

      table += "\n"

      # Add line breaks under headers
      column_lengths.each { |length|
        table += (('-' * length) + (' ' * gutter))
      }

      table += "\n"

      # Add rows
      data.each { |row|
        headers.each_with_index { |header, i|
          table += format_row_entry.call(row[header], i)
        }

        table += "\n"
      }

      table
    end
972156
def generate_table(self, rows):
        
        table = PrettyTable(**self.kwargs)
        for row in self.rows:
            if len(row[0]) < self.max_row_width:
                appends = self.max_row_width - len(row[0])
                for i in range(1, appends):
                    row[0].append("-")

            if row[1] is True:
                self.make_fields_unique(row[0])
                table.field_names = row[0]
            else:
                table.add_row(row[0])
        return table
749951
def get_row_list(self, row_idx):
        

        try:
            row = self._rows[row_idx]
        except TypeError:
            row = self._rows[self._row_name_idx[row_idx]]

        if isinstance(row, list):
            extra = [ self._default_value ] * (len(self._column_name_list) - len(row))
            return row + extra

        else:
            if row_idx not in self._row_memo:
                self._row_memo[row_idx] = [ row[k] if k in row else self._default_value for k in self._column_name_list ]

            return self._row_memo[row_idx]
517107
def iterrows(self, workbook=None):
        
        resolved_tables = []
        max_height = 0
        max_width = 0

        # while yielding rows __formula_values is updated with any formula values set on Expressions
        self.__formula_values = {}

        for name, (table, (row, col)) in list(self.__tables.items()):
            # get the resolved 2d data array from the table
            #
            # expressions with no explicit table will use None when calling
            # get_table/get_table_pos, which should return the current table.
            #
            self.__tables[None] = (table, (row, col))
            data = table.get_data(workbook, row, col, self.__formula_values)
            del self.__tables[None]

            height, width = data.shape
            upper_left = (row, col)
            lower_right = (row + height - 1, col + width - 1)

            max_height = max(max_height, lower_right[0] + 1)
            max_width = max(max_width, lower_right[1] + 1)
            
            resolved_tables.append((name, data, upper_left, lower_right))

        for row, col in self.__values.keys():
            max_width = max(max_width, row+1)
            max_height = max(max_height, col+1)

        # Build the whole table up-front. Doing it row by row is too slow.
        table = [[None] * max_width for i in range(max_height)]
        for name, data, upper_left, lower_right in resolved_tables:
            for i, r in enumerate(range(upper_left[0], lower_right[0]+1)):
                for j, c in enumerate(range(upper_left[1], lower_right[1]+1)):
                    table[r][c] = data[i][j]

        for (r, c), value in self.__values.items():
            if isinstance(value, Value):
                value = value.value
            if isinstance(value, Expression):
                if value.has_value:
                    self.__formula_values[(r, c)] = value.value
                value = value.get_formula(workbook, r, c)
            table[r][c] = value

        for row in table:
            yield row
233728
def get_output_row_heights(table, spans):
    
    heights = []
    for row in table:
        heights.append(-1)

    for row in range(len(table)):
        for column in range(len(table[row])):
            text = table[row][column]
            span = get_span(spans, row, column)
            row_count = get_span_row_count(span)
            height = len(text.split('\n'))
            if row_count == 1 and height > heights[row]:
                heights[row] = height

    for row in range(len(table)):
        for column in range(len(table[row])):
            span = get_span(spans, row, column)
            row_count = get_span_row_count(span)
            if row_count > 1:
                text_row = span[0][0]
                text_column = span[0][1]

                end_row = text_row + row_count

                text = table[text_row][text_column]

                height = len(text.split('\n')) - (row_count - 1)

                add_row = 0
                while height > sum(heights[text_row:end_row]):
                    heights[text_row + add_row] += 1
                    if add_row + 1 < row_count:
                        add_row += 1
                    else:
                        add_row = 0
    return heights