Last active
November 29, 2016 18:50
-
-
Save rheajt/da69f60cabf398c7333dfbc33b55447e to your computer and use it in GitHub Desktop.
filter achieve 3000 data from the sidebar
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
function onOpen() { | |
SpreadsheetApp.getUi() | |
.createAddonMenu() | |
.addItem('Open Sidebar', 'openSidebar') | |
.addToUi(); | |
} | |
function onInstall() { | |
onOpen(); | |
} | |
function openSidebar() { | |
return SpreadsheetApp.getUi() | |
.showSidebar(HtmlService.createHtmlOutputFromFile('Sidebar').setTitle('A3K Import Data')); | |
} | |
function importCSV(csv) { | |
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data'); | |
sheet.clear(); | |
var sheetData = sheet.getDataRange().getValues(); | |
var newCSV = Utilities.parseCsv(csv); | |
newCSV.forEach(function(row, ind) { | |
if(ind === 0) { | |
sheet.appendRow([ | |
'Student Name', | |
'Student Number', | |
'Activities Completed', | |
'Total Attempts', | |
'Success Percentage' | |
]); | |
} else { | |
var studentName = row[4] + ' ' + row[5], | |
studentNumber = row[6], | |
activitiesCompleted = +row[14], | |
totalAttempts = +row[13] + +row[14], | |
success = Math.floor((activitiesCompleted / totalAttempts) * 100); | |
sheet.appendRow([studentName, studentNumber, activitiesCompleted, totalAttempts, success]); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment