rmalcoriza

weatherAPI - AppScript

Jul 9th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. function recalculateSheet() {
  2.  
  3. var ss = SpreadsheetApp.openById("replaceWithSheetID");
  4. var sheet = ss.getSheetByName("weatherAPI");
  5. var timeCell = sheet.getRange('I1');
  6. var cell = sheet.getRange('C2:C90');
  7.  
  8. var cellFormula2;
  9.  
  10. var now = new Date();
  11.  
  12.  
  13. timeCell.setValue(now + " " + now.getHours() + ":" + now.getMinutes());
  14. cell.clearContent();
  15. SpreadsheetApp.flush();
  16. Utilities.sleep(2000);
  17. for(i=2;i<=90;i++){
  18. cellFormula2 = sheet.getRange('C'+[i]);
  19. cellFormula2.setValue('=ImportJSON(CONCATENATE("http://api.openweathermap.org/data/2.5/weather?q=",B'+[i]+',",uk&units=metric&appid=15eac9adb8223be2076251d4fb16f884"),"/main/temp","noInherit,noTruncate,noHeaders")');
  20. }
  21.  
  22.  
  23. }
Add Comment
Please, Sign In to add comment