Hi guys,
hope this is not a duplicate topic or something already ask by someone else
I will explain what I've done to create a loop to call successive pages from an API and merge the result in a CSV file to load my DB
Context:
I have to update a database with a list of companies send by this free API. the API return a CSV or a JSON (I chose to work on the CSV because I can manage more row according the API specification)
All the documentation can be found here (In french only) Sirene - Catalogue API Insee
What I'm trying to do
I want to be able in the case that I have more than 10000 row returned by the API to relaunch call until I arrive at the end of the row I have to receive.
example:
If I have to process 15000 row, I have to do 2 call to this API.
1. Iteration calculation
Here I calculate the MAX number of iteration I will have to do.
Parameter is calculate with "round(asnumber([X-Total-Count])/10000,0)" where [X-Total-Count] is the amount of row updated at sysdate -1
2. Iteration start
in this step I run my second module (responseToCSV) and push my parameter "numberofiteration" to a paramter on the second module called "page number".
3. What is executed
my second module contain a succession of action (table) that will push data to the CSV.
I create 3 parameter to make the loop
pagenumber : receive the data previously calculated and called "numberofiteration"
pagetocall : an empty number parameter
Parameter : dynamics parameter calculate with
if(isempty({pagenumber}),0,(if({pagetocall}>0 and {pagetocall}<{pagenumber},{pagetocall}+1,{pagenumber})))
When I launch the project, it run without any problem or warning or alert.
From my point of view, it seems to work.
the questions are:
- I am right when I think it's work will it only make 1 call
- If not What I've missed? Can you please help me?
- did I'm using Easymorph on the good way?
I attach my process if you want to take a look at.
thanks in advance for your help.
Cheers
InseeDailySIREN.morph (51.9 KB)