Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def value_range(self, rng):
"""Returns a list of values in a range."""
start, end = rng.split(':')
(row_offset, column_offset) = a1_to_rowcol(start)
(last_row, last_column) = a1_to_rowcol(end)
out = []
for col in self.values[row_offset - 1:last_row]:
out.extend(col[column_offset - 1:last_column])
return out
def get_cell_as_tuple(cell):
"""Take cell in either format, validate, and return as tuple."""
if type(cell) == tuple:
if (
len(cell) != 2
or not np.issubdtype(type(cell[ROW]), np.integer)
or not np.issubdtype(type(cell[COL]), np.integer)
):
raise TypeError("{0} is not a valid cell tuple".format(cell))
return cell
elif isinstance(cell, basestring):
if not match("[a-zA-Z]+[0-9]+", cell):
raise TypeError("{0} is not a valid address".format(cell))
return a1_to_rowcol(cell)
else:
raise TypeError("{0} is not a valid format".format(cell))
:param value_render_option: (optional) Determines how values should be
rendered in the the output. See
`ValueRenderOption`_ in the Sheets API.
:type value_render_option: str
.. _ValueRenderOption: https://developers.google.com/sheets/api/reference/rest/v4/ValueRenderOption
Example:
>>> worksheet.acell('A1')
"""
return self.cell(
*(a1_to_rowcol(label)),
value_render_option=value_render_option
)