# Importjson script multiple imports

**URL:** <https://community.glideapps.com/t/importjson-script-multiple-imports/13032>\
**Category:** Ask for Help\
**Created:** [July 24, 2020, 6:35am UTC](https://community.glideapps.com/t/importjson-script-multiple-imports/13032 "2020-07-24T06:35:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Krivo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/krivo/32/5363_2.png) [@Krivo](https://community.glideapps.com/u/Krivo)\
**Post date:** [July 24, 2020, 6:35am UTC](https://community.glideapps.com/t/importjson-script-multiple-imports/13032/1 "2020-07-24T06:35:03Z")

</div>

How to do?  
Case:  
Import data from external source where response data is delivered in Json.  
Dataset is large and will be delivered in chunks  
A chunk is 500 objects and part of the response of the first chunk will be an id for the next chunk. This means that the request for the second chunk can only be performed when data from the first chunk has been fetched.

I want the imported chunks to be listed after each other  
Chunk 1’s data  
Chunk 2’s data  
Etc

Anyone?

Extra info:  
I found out how to get the first chunk by updating a field in google sheet and then onchange event trigger to run a script which is actually just inserting a new formula in a cell like =importjson(xxx?123) - 123 is just a incremented value. The importjson will then run.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [July 24, 2020, 10:32am UTC](https://community.glideapps.com/t/importjson-script-multiple-imports/13032/2 "2020-07-24T10:32:06Z")

</div>

Does ImportHTML only allow 500 rows per import or is there something else here?

I was thinking of using an Array\_Constrain or Query, then let’s say verify if cell A501 is not empty (so the first batch has been completed), then push the formula to cell A502 for it to continue the next batch.

---

<div class="post-metadata">

**Author:** ![Krivo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/krivo/32/5363_2.png) [@Krivo](https://community.glideapps.com/u/Krivo)\
**Post date:** [July 24, 2020, 10:58am UTC](https://community.glideapps.com/t/importjson-script-multiple-imports/13032/3 "2020-07-24T10:58:15Z")

</div>

@ThinhDinh  
It is the provider that can only send 500 objects at a time. I’m using importjson.

I only input a importjson statement in A2 cell. Then cell A2-A501 is filled with data.

I’m unsure how to use the array\_constrain or query to get the value to A502. I must look into that

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [July 24, 2020, 11:08am UTC](https://community.glideapps.com/t/importjson-script-multiple-imports/13032/4 "2020-07-24T11:08:39Z")

</div>

Oh sorry I meant to write ImportJSON.

So when you have the second import it will automatically detect the next 500 items?

---

<div class="post-metadata">

**Author:** ![Krivo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/krivo/32/5363_2.png) [@Krivo](https://community.glideapps.com/u/Krivo)\
**Post date:** [July 24, 2020, 11:13am UTC](https://community.glideapps.com/t/importjson-script-multiple-imports/13032/5 "2020-07-24T11:13:37Z")

</div>

@ThinhDinh well, in the first import you will find information about the next import. Here the next object id will be given. But you will have do do a new request. And data should be inserted in line 502–\>

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [July 24, 2020, 11:48am UTC](https://community.glideapps.com/t/importjson-script-multiple-imports/13032/6 "2020-07-24T11:48:58Z")

</div>

So would a flow like this work?

A script triggers applying a formula to cell A2, first 500 rows are returned.

Check if A501 is empty or not (probably give a sleep function of 30 seconds or something). If not empty, get new object ID, apply new function to A502 and so on.

---

<div class="post-metadata">

**Author:** ![Krivo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/krivo/32/5363_2.png) [@Krivo](https://community.glideapps.com/u/Krivo)\
**Post date:** [July 24, 2020, 12:17pm UTC](https://community.glideapps.com/t/importjson-script-multiple-imports/13032/7 "2020-07-24T12:17:50Z")

</div>

@ThinhDinh jep. Something like that. I would like to avoid sleep thing as I might need to return maybe 5000 objects.  
And actually would like to avoid loading the whole dataset again when sheets opens
