Created
September 12, 2011 13:30
-
-
Save chocokanpan/1211245 to your computer and use it in GitHub Desktop.
DevQuiz Google Apps Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function inportJsonByGdd2011() { | |
var data = UrlFetchApp.fetch("http://gdd-2011-quiz-japan.appspot.com/apps_script/data?param=3800952189735731210"); | |
// var data = UrlFetchApp.fetch("http://gdd-2011-quiz-japan.appspot.com/apps_script/sample"); | |
var json = Utilities.jsonParse(data.getContentText()); | |
var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
for(var i in json){ | |
var city = json[i]; | |
ss.insertSheet(city["city_name"]); | |
var sheet = ss.getActiveSheet(); | |
for(var d in city["data"]){ | |
var capacity = city["data"][d]["capacity"]; | |
var usage = city["data"][d]["usage"]; | |
var raw = parseInt(d)+1; | |
var n_capacity = sheet.getRange(raw,1,1,1).setValue(capacity).getA1Notation(); | |
var n_usage = sheet.getRange(raw,2,1,1).setValue(usage).getA1Notation(); | |
sheet.getRange(raw,3,1,1).setFormula("="+n_usage+"/"+n_capacity).setNumberFormat("##.00%"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment