Answer the question
In order to leave comments, you need to log in
How to get "clean" cell value in Google Sheets?
when reading data from a google sheet cell, I get the following value
'values': }
{'majorDimension': 'COLUMNS', 'range': 'guid!B2', 'values': }
8241279c-4945-4066-977f-15db2943be44
and102126989
Answer the question
In order to leave comments, you need to log in
You just need to extract the value from the JSON . if you look carefully, you have a dictionary in front of you, and the desired element is obtained by key.
And what you are doing is described in detail here
, well, as a homework, understand the lines of code
response = {'majorDimension': 'COLUMNS', 'range': 'guid!B2', 'values': }
response.get('values', 'No key values')
result = response.get('values', 'No key values')
type(result)
<class 'list'>
result[0]
['102126989']
result[0][0]
'102126989'
values = result[0][0]
values
'102126989'
v = response['values'][0][0]
v
'102126989'
import json
from_google_sheet = '[{"majorDimension": "COLUMNS", "range": "guid!B2", "values": },{"majorDimension": "COLUMNS", "range": "guid!B2", "values": },{"majorDimension": "COLUMNS", "range": "guid!B2", "values": }]'
json_from_google_sheet = json.loads(from_google_sheet)
json_from_google_sheet
[{'majorDimension': 'COLUMNS', 'range': 'guid!B2', 'values': }, {'majorDimension': 'COLUMNS', 'range': 'guid!B2', 'values': }, {'majorDimension': 'COLUMNS', 'range': 'guid!B2', 'values': }]
type(json_from_google_sheet)
<class 'list'>
for values in json_from_google_sheet:
print(values['values'][0][0])
1
2
3
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question