# Loop routine to load google sheet data to firebase

**URL:** <https://community.thunkable.com/t/loop-routine-to-load-google-sheet-data-to-firebase/2647269>\
**Category:** Questions about Thunkable X\
**Created:** [October 16, 2023, 4:19pm UTC](https://community.thunkable.com/t/loop-routine-to-load-google-sheet-data-to-firebase/2647269 "2023-10-16T16:19:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![wmnewlon11f2](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/wmnewlon11f2/32/162742_2.png) [@wmnewlon11f2](https://community.thunkable.com/u/wmnewlon11f2)\
**Post date:** [October 16, 2023, 4:19pm UTC](https://community.thunkable.com/t/loop-routine-to-load-google-sheet-data-to-firebase/2647269/1 "2023-10-16T16:19:02Z")

</div>

Hello, wishing to load google sheets data into firebase. I’m using a spreadsheet to capture some intermediate data before I transfer to firebase for permanent storage (I could also use local data table, but have challenges troubleshooting in preview mode.

The [google sheets data](https://docs.google.com/spreadsheets/d/1C5qFYjU-wvWf68HRRJUG0hT1B-nnMWNVOIxdHbveWZ4/edit?usp=sharing) has multiple rows of data so I need to write a “loop” routine to work through each row and load into firebase.

This is my first attempt at the routine (failed after multiple tries).

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/a/4a81e8b52855fa6937ad27e869a436140694e58a.png)

I’m creating an event (in GameSummaryForms) tagging with a date (YYYYMMDD) and loading game number and game date characteristics.

Then I’m creating a sub-tag group (Incidents) to load all the incident data and assigning a unique incident ID (Event# and Offender), then loading incident time and offender characteristics.

Firebase Tags/SubTags look like:  
GameSummaryForms

> > > > 20231015  
> > > > . \>\>\>\> GameNumber: text  
> > > > . \>\>\>\> GameDate: text  
> > > > . \>\>\>\> Incidents  
> > > > . \>\>\>\>. \>\>\>\> Event#Offender1  
> > > > . \>\>\>\>. \>\>\>\> Event#Offender2  
> > > > . \>\>\>\>. \>\>\>\> Event#Offender3

Would appreciate any help in solving this challenge. thanks!

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [October 16, 2023, 6:48pm UTC](https://community.thunkable.com/t/loop-routine-to-load-google-sheet-data-to-firebase/2647269/2 "2023-10-16T18:48:50Z")

</div>

What specifically is or is not working?

Are you able to set a single cloud variable path (without a loop) successfully as a test?

Have you tried introducing a delay inside the loop? Often, loops that access cloud-based storage need to time to complete. Try a Wait 0.03 seconds block or even a Wait 0 seconds block to see if that helps.

---

<div class="post-metadata">

**Author:** ![wmnewlon11f2](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/wmnewlon11f2/32/162742_2.png) [@wmnewlon11f2](https://community.thunkable.com/u/wmnewlon11f2)\
**Post date:** [October 16, 2023, 6:53pm UTC](https://community.thunkable.com/t/loop-routine-to-load-google-sheet-data-to-firebase/2647269/3 "2023-10-16T18:53:00Z")

</div>

First part is working (loading game number and date to GameSummaryForms \>\> Date

The "for each item “J” DO block is not working.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [October 16, 2023, 6:59pm UTC](https://community.thunkable.com/t/loop-routine-to-load-google-sheet-data-to-firebase/2647269/4 "2023-10-16T18:59:09Z")

</div>

What I’m suggesting is that you need to try to set a value with a sample endpoint from the loop (/Incidents/Event#…) but without using a loop. Just a standalone test to make sure that’s possible. Not just the partial path that you’re trying above the loop. But again, if your paths are definitely correct then a Wait block may be helpful.

---

<div class="post-metadata">

**Author:** ![wmnewlon11f2](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/wmnewlon11f2/32/162742_2.png) [@wmnewlon11f2](https://community.thunkable.com/u/wmnewlon11f2)\
**Post date:** [October 17, 2023, 2:53pm UTC](https://community.thunkable.com/t/loop-routine-to-load-google-sheet-data-to-firebase/2647269/5 "2023-10-17T14:53:40Z")

</div>

tatiang - good insight, thank you.

I added timers … no success.

I then re-wrote the load routine (2nd part) by removing the loop and attempting to load the first row in the google spreasheet (just grabbed rowID and inserted in the get value blocks). No success. For some reason (I’m still trying to determine), it wasn’t loading to firebase. I’m checking the join structure on the set cloud variable to ensure the tags/subtags are correct. I’m also going to re-program the loading so that I pass one record at a time (instead of multiple records).

Once successful, I will tackle the multiple record loading at one time in the future.

thanks again for your insght.

---

<div class="post-metadata">

**Author:** ![wmnewlon11f2](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/wmnewlon11f2/32/162742_2.png) [@wmnewlon11f2](https://community.thunkable.com/u/wmnewlon11f2)\
**Post date:** [October 18, 2023, 12:24am UTC](https://community.thunkable.com/t/loop-routine-to-load-google-sheet-data-to-firebase/2647269/6 "2023-10-18T00:24:02Z")

</div>

Another insight on my part … Firebase doesn’t allow # characters in the tag/subtag structure. Your program will not load any data to firebase. This was the problem from the start.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [January 16, 2024, 12:24am UTC](https://community.thunkable.com/t/loop-routine-to-load-google-sheet-data-to-firebase/2647269/7 "2024-01-16T00:24:36Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
