Skip to content

Instantly share code, notes, and snippets.

View phillypb's full-sized avatar

Phil Bainbridge phillypb

View GitHub Profile
/*
Loop through a folder of CSV files.
Capture tutor name (from file name) and code the file ID / Module Code / Group No with it in a JavaScript Object.
Collates/sorts all files together for each individual tutor.
End result is ability to loop through JavaScript Object and action CSV files
belonging to each tutor in-turn.
Collated data will look like this:
{Micky Mouse=[{fileId=1BRv0IhTxYxhsYbDN85DkpMqrTPyJHXyK, group=Grp 05.csv, moduleCode=CDE}, {moduleCode=CDE, fileId=1dmwVbPdwNQbOg9nfO98RD213QpKOLuqk, group=Grp 01.csv}], Jane Doe=[{group=Grp 04.csv, fileId=1z8O6jnm8INdZf9NWZBCoWTvB0zTEQDDe, moduleCode=ABC}, {moduleCode=ABC, fileId=1MnenQwueMKWssWlBOEaM8lcozB9ghYEn, group=Grp 03.csv}, {fileId=1-kh1Vp6It4LvVNSahUMkP529hu4-_es9, moduleCode=ABC, group=Grp 02.csv}]}
*/
/*
Loop through a folder of CSV files.
Capture tutor name (from file name) and file ID in a JavaScript Object.
Collates/sorts all files together for each individual tutor.
End result is ability to loop through JavaScript Object and action CSV files
belonging to each tutor in-turn.
Collated data will look like this:
{"Jane Doe":["1-kh1Vp6It4LvVNSahUMkP529hu4-_es9","1z8O6jnm8INdZf9NWZBCoWTvB0zTEQDDe","1MnenQwueMKWssWlBOEaM8lcozB9ghYEn"],"Micky Mouse":["1BRv0IhTxYxhsYbDN85DkpMqrTPyJHXyK","1dmwVbPdwNQbOg9nfO98RD213QpKOLuqk"]}
*/
/*
Sort through an array and remove any duplicate values.
Does not account for changes in case-sensitivity.
*/
function removeDuplicates() {
// array of duplicates
var rawArray = ['Dave', 'Jim', 'Dave', 'Nicky', 'Nicky', 'Bob', 'Bob', 'Bob'];
/*
Testing the ability to search a 'Catch' error message and display a specific
one based upon it.
*/
function breakMe() {
try {
function createSheets() {
try {
// log event
logEvent("Starting 'createSheets' Function");
// get the 'Welcome' Sheet
/*
Get values from the Spreadsheet to pass to other Functions.
*/
function getSpreadsheetData() {
logEvent('Starting script.');
// update status cell
statusUpdate('Process is running', '#ff9900');
/*
Get Survey - https://api.qualtrics.com/73d7e07ec68b2-get-survey
*/
function getSurveyDetails() {
// Qualtrics API Token: Qualtrics > Account Settings > Qualtrics IDs > API Token
var apiToken = 'YOUR API TOKEN HERE';
/*
The following Google Apps Script is designed to loop through a folder of CSV files in Google Drive, extract the data, create a Google Sheet file per CSV, and insert the data into specific rows/columns.
*/
function createSheets() {
// get template Google Sheet for copying
var templateSheet = DriveApp.getFileById('1Rj-TGRW01kx7TEVU-nXywn0yJ1GC96pgegWnuJ0Vtag');
/*
Function to search for all files within the Google Drive 'Shared with me' space
and output the results into a Google Sheet.
*/
/**
* @OnlyCurrentDoc
*/
function searchDrive() {
/** * @OnlyCurrentDoc */
function autofill() {
// get active sheet
var sheet = SpreadsheetApp.getActiveSheet();
// get last row of data for later pasting into
var lastRow = sheet.getLastRow();