From c02889ee13b5317bacb0cc673abddb5ea90cc18f Mon Sep 17 00:00:00 2001 From: Tom Gillespie Date: Tue, 21 Jun 2022 15:45:40 -0700 Subject: [PATCH] sheets update python type -> sheets api type mapping for _obj_value --- pyontutils/sheets.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pyontutils/sheets.py b/pyontutils/sheets.py index a9696d81..50d653e0 100644 --- a/pyontutils/sheets.py +++ b/pyontutils/sheets.py @@ -3,6 +3,7 @@ import pickle import itertools from pathlib import Path +from numbers import Number from urllib.parse import urlparse import idlib import htmlfn as hfn @@ -418,14 +419,21 @@ def _obj_range(self): def _obj_update(self): return {'updateCells': { 'rows': [ - {'values': [ - {'userEnteredValue': {'stringValue': self._value_str,}},]},], + {'values': [self._obj_value(),]},], 'fields': 'userEnteredValue', #'start': self._obj_coord(), # only need one of start or range 'range': self._obj_range(),}} def _obj_value(self): - return {'userEnteredValue': {'stringValue': self._value_str,}} + value = self._value_str + if isinstance(value, bool): + d = {'boolValue': value} + elif isinstance(value, Number): + d = {'numberValue': value} + else: + d = {'stringValue': value} + + return {'userEnteredValue': d} class Row: