Created
January 7, 2019 19:59
-
-
Save nebula2/0d1043b87da650c6a9f1261e8e98966f to your computer and use it in GitHub Desktop.
The result of some boredom.
This file contains 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
//Imports tt2master small export string | |
//Change variables according to your locations | |
function tt2MasterImport() { | |
var sheetname = "Input"; //sheet name for input | |
var artRow = 2; //starting row for artifact input | |
var artKeyCol = 1; //column for artifact key | |
var artValCol = 2; //column for artifact value | |
var spRow = 2; //starting row for skill input | |
var spKeyCol = 3; //column for skill key | |
var spValCol = 4; //column for skill value | |
var doc = SpreadsheetApp.getActiveSpreadsheet(); | |
var temp = doc.getSheetByName(sheetname); | |
//make sure that the input sheet exists | |
if (!doc.getSheetByName(sheetname)){ | |
var sheet = doc.insertSheet(sheetname); | |
} else { | |
var sheet = doc.getSheetByName(sheetname); | |
//clear old data | |
sheet.getRange(2, 1, sheet.getLastRow(), sheet.getMaxColumns()).clear({contentsOnly:true}); | |
} | |
//get json | |
var rawjson = doc.getSheetByName("Input").getRange(1, 1).getDisplayValue(); | |
//parse json | |
var dataAll = JSON.parse(rawjson); | |
//get artifact data | |
var artData = dataAll._artLvls; | |
//output artifact data | |
for(var i=0;i < artData.length; i++){ | |
var keyRange = sheet.getRange(artRow, artKeyCol) | |
keyRange.setValue(artData[i].ID); | |
var valRange = sheet.getRange(artRow, artValCol); | |
valRange.setValue(artData[i].Level); | |
artRow++; | |
} | |
//get skill data | |
var spData = dataAll._skillLvls; | |
//output skill data | |
for(var i=0;i < spData.length; i++){ | |
var keyRange = sheet.getRange(spRow, spKeyCol) | |
keyRange.setValue(spData[i].TalentID); | |
var valRange = sheet.getRange(spRow, spValCol); | |
valRange.setValue(spData[i].CurrentLevel); | |
spRow++; | |
} | |
//for output | |
var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
ss.toast("Done. Inserted "+(artData.length + spData.length) +" items"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment