title: Save a json/csv file (fetched from an API) to a spreadsheet document without using a loop - Google Apps Script
body: <p>I can fetch the data using two different urls depending whether I want to file to be csv or json.</p>
  <ol>
  <li><strong>CSV edition</strong></li>
  </ol>
  <p>In the case of the csv url I do the following:</p>
  <pre><code>  var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getSheetByName(&quot;data&quot;)
  
  get_url=&quot;https://opendata.rdw.nl/resource/m9d7-ebf2.csv? 
      datum_tenaamstelling=20200404%20&amp;$limit=20000&quot;;
  
    var result_data = UrlFetchApp.fetch(get_url);
    var raw_data = result_data.getContentText()
    Logger.log(raw_data);
  </code></pre>
  <p>I end up with a string that I can not store it to the spreadsheet file without using a loop.</p>
  <ol start="2">
  <li><strong>JSON edition</strong></li>
  </ol>
  <p>Using the json url, I am doing the following:</p>
  <pre><code>var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName(&quot;data&quot;)
  
  get_url=&quot;https://opendata.rdw.nl/resource/m9d7-ebf2.json? 
  datum_tenaamstelling=20200404%20&amp;$limit=20000&quot;;
  
  var result_data = UrlFetchApp.fetch(get_url, options);
  var raw_data = result_data.getContentText()
  var json_list = JSON.parse(raw_data)
  
   for(var i = 0; i &lt; json_list.length; i++) {
      var obj = json_list[i];
  
      Logger.log(obj.merk);
      
      sheet.appendRow([obj.kenteken, 
                       obj.merk, 
                       obj.catalogusprijs, 
                       obj.datum_eerste_afgifte_nederland,
                       obj.datum_eerste_toelating,
                       obj.datum_tenaamstelling
                      ]);
  }
  </code></pre>
  <p>Which again I end up using an iteration which is not practical if I want to store 20000 rows to the spreadsheet. After sometime it stops and returns a runtime error.</p>
  <p>Is there any way I can directly copy the data to the spreadsheet file?
  For example to do something like that:</p>
  <pre><code>sheet.getRange(1, 1,raw_data.length,raw_data[0].length).setValues(raw_data);
  </code></pre>