'Append rows to a Plotly grid.
`rows` is an iterable of rows, where each row is a
list of numbers, strings, or dates. The number of items
in each row must be equal to the number of columns
in the grid. If appending rows to a grid with columns of
unequal length, Plotly will fill the columns with shorter
length with empty strings.
Only one of `grid` and `grid_url` needs to specified.
`grid` is a ploty.grid_objs.Grid object that has already been
uploaded to plotly with the grid_ops.upload method.
`grid_url` is a unique URL of a `grid` in your plotly account.
Usage example 1: Upload a grid to Plotly, and then append rows
from plotly.grid_objs import Grid, Column
import plotly.plotly as py
column_1 = Column([1, 2, 3], \'time\')
column_2 = Column([5, 2, 7], \'voltage\')
grid = Grid([column_1, column_2])
py.grid_ops.upload(grid, \'time vs voltage\')
# append a row to the grid
row = [1, 5]
py.grid_ops.append_rows([row], grid=grid)
Usage example 2: Append a row to a grid that already exists on Plotly
from plotly.grid_objs import Grid
import plotly.plotly as py
grid_url = \'https://plot.ly/~chris/3143\'
row = [1, 5]
py.grid_ops.append_rows([row], grid=grid_url)'

@classmethod
def append_rows(cls, rows, grid=None, grid_url=None):

    grid_id = parse_grid_id_args(grid, grid_url)
    grid_ops.ensure_uploaded(grid_id)
    if grid:
        n_columns = len([column for column in grid])
        for (row_i, row) in enumerate(rows):
            if (len(row) != n_columns):
                raise exceptions.InputError('The    number    of    entries    in    each    row    needs    to    equal    the    number    of    columns    in    the    grid.    Row    {0}    has    {1}    {2}    but    your    grid    has    {3}    {4}.    '.format(row_i, len(row), ('entry' if (len(row) == 1) else 'entries'), n_columns, ('column' if (n_columns == 1) else 'columns')))
    fid = grid_id
    v2.grids.row(fid, {'rows': rows})
    if grid:
        longest_column_length = max([len(col.data) for col in grid])
        for column in grid:
            n_empty_rows = (longest_column_length - len(column.data))
            empty_string_rows = ['' for _ in range(n_empty_rows)]
            column.data.extend(empty_string_rows)
        column_extensions = zip(*rows)
        for (local_column, column_extension) in zip(grid, column_extensions):
            local_column.data.extend(column_extension)
