d3dname commited on
Commit
ddaaf1b
·
verified ·
1 Parent(s): a9d075c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -237,12 +237,19 @@ with middle:
237
  query_result = notion.databases.query(database_id=database_id)
238
  data = []
239
  for result in query_result["results"]:
240
- name = result["properties"]["Name"]["title"][0]["text"]["content"]
241
- age = result["properties"]["Age"]["number"]
242
- location = result["properties"]["Location"]["rich_text"][0]["text"]["content"]
 
 
 
 
 
 
243
  data.append({"Name": name, "Age": age, "Location": location})
244
 
245
  return pd.DataFrame(data)
 
246
 
247
  # Display the data in a table
248
  st.subheader("Stored Data")
 
237
  query_result = notion.databases.query(database_id=database_id)
238
  data = []
239
  for result in query_result["results"]:
240
+ # Safely extract the "Name" property
241
+ name = result["properties"]["Name"]["title"][0]["text"]["content"] if result["properties"]["Name"]["title"] else "No Name"
242
+
243
+ # Safely extract the "Age" property
244
+ age = result["properties"]["Age"]["number"] if result["properties"]["Age"]["number"] is not None else "No Age"
245
+
246
+ # Safely extract the "Location" property
247
+ location = result["properties"]["Location"]["rich_text"][0]["text"]["content"] if result["properties"]["Location"]["rich_text"] else "No Location"
248
+
249
  data.append({"Name": name, "Age": age, "Location": location})
250
 
251
  return pd.DataFrame(data)
252
+
253
 
254
  # Display the data in a table
255
  st.subheader("Stored Data")