Skip to content

Commit

Permalink
auto fech if data not given range, nithinmurali#217
Browse files Browse the repository at this point in the history
  • Loading branch information
nithinmurali committed May 14, 2018
1 parent 91ccfb8 commit 7b8e915
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions pygsheets/datarange.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ def __init__(self, start=None, end=None, worksheet=None, name='', data=None, nam
if len(data) == self._end_addr[0] - self._start_addr[0] + 1 and \
len(data[0]) == self._end_addr[1] - self._start_addr[1] + 1:
self._data = data
else:
self.fetch()
else:
self.fetch()

self._linked = True

self._name_id = name_id
Expand Down
8 changes: 4 additions & 4 deletions pygsheets/worksheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def get_row(self, row, returnas='matrix', include_tailing_empty=True, include_em
return self.get_values((row, 1), (row, self.cols), returnas=returnas,
include_tailing_empty=include_tailing_empty, include_empty_rows=include_empty_rows)[0]

# TODO
# TODO Dosent work
def get_col(self, col, returnas='matrix', include_tailing_empty=True, include_empty_rows=False):
"""Returns a list of all values in column `col`.
Expand Down Expand Up @@ -971,7 +971,7 @@ def create_named_range(self, name, start, end):
:param name: Name of the range.
:param start: Top left cell address (label or coordinates)
:param end: Bottom right cell address (label or coordinates)
:return :class:`DataRange`
:returns :class:`DataRange`
"""
if not self._linked: return False

Expand All @@ -997,9 +997,9 @@ def get_named_range(self, name):
Reference: https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#namedrange
:param name: Name of the named range to be retrieved.
:return: :class:`DataRange`
:returns: :class:`DataRange`
:raises RangeNotFound, if no range matched the name given.
:raises RangeNotFound: if no range matched the name given.
"""
if not self._linked: return False

Expand Down

0 comments on commit 7b8e915

Please sign in to comment.