Created
April 28, 2019 20:17
-
-
Save jwithington/bba099f5ade872e425d47ef71484688b to your computer and use it in GitHub Desktop.
Final (for now), filtering for all the things
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 columnsExportText() { | |
//create main array to store data | |
var everything = []; | |
// get values from active sheet | |
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets(); | |
// loop over each tab/sheet | |
for (var j = 0; j < sheets.length ; j++ ) { | |
var collected = []; // array to collect each loop | |
var sheet = sheets[j]; | |
var tabName = sheet.getName(); | |
var range = sheet.getRange(2, 1, sheet.getLastRow() -1, 2); // checks from row 2, column one, to last row, column 2 | |
var data = range.getValues(); | |
// loop through and add info to collection with format of Text : "Text" | |
var i = data.length; | |
while (i--) { | |
if ((data[i][0] != "") && (data[i][1] != "")) // only collects if both column one and two are not empty | |
collected[i] = ('\n' + data[i][0] + ' : "' + data[i][1] + '"'); | |
completedLoop = "\n" + tabName + " :\n{" + collected.filter(Boolean); //filters out blank or incomplete rows | |
} | |
var everything = everything.concat(completedLoop + "\n}"); | |
} | |
// create date, format string, and name the file | |
var formattedDate = Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd-HH:mm"); | |
var exportString = everything; | |
var docName = "Exported-Data-" + formattedDate; | |
//export | |
var exportToText = DriveApp.createFile(docName, exportString, MimeType.PLAIN_TEXT); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment