Hi there!
I am experiencing a bit of an issue, and I feel I’m just misunderstanding the correct process for obtaining this data.
I am trying to use the Python API to grab data from my Grist sheet, the problem is that the data that I am trying to grab is referenced.
I have a table called “Clients” containing the client names. I also have a table called “Client Pages” where I am adding a reference to client, and adding their pages in a list.
I am trying to pull the data from the “Client Pages” sheet to create a dictionary similar to this:
clients = {"client1": ["page11", "page12"], "client2": ["page21", "page22", "page23"], "client3": ["page31", "page32"]}
This is what I’m trying:
def get_grist_clients():
DOC_ID = "xxxxx"
api_key = "xxxxx"
api = GristDocAPI(DOC_ID, server="https://xxxx.xxx.xxx", api_key=api_key)
data = api.fetch_table("xxxxx")
for page_line in data:
client = page_line.Client
page = page_line.Page
print(client)
print(page)
With this code, the client is equal the the references cell id, rather than its value so it prints numbers, while page works just fine as it is not referenced, but direct value in the cell.
How can I pull the text value instead of the number from the referenced cell? Based on what I can tell it doesn’t seem possible this way, and I will have to pull it from the non-referenced sheet instead, overcomplicating things?