Good afternoon everyone
I am importing data from a Google Spreadsheet as JavaScript objects but I cannot seem to be able to use postProcess option to modify the data after it has been processed by tabletop.js.
This is the example I have taken from GitHub (please note I am still a beginner). I have replace the names after element["___"] with the names of my columns and it won’t do anything.
postProcess: function(element) {
// Combine first and last name into a new column
element["full_name"] = element["first_name"] + " " + element["last_name"];
// Convert string date into Date date
element["timestamp"] = Date.parse(element["displaydate"]);
}
I have tried to replace function(element) with function(data). This is the rest of my code:
var publicSpreadsheetUrl = 'https://docs.google.com/spreadsheets/d/1HQhlecn-i9s33Olf4OLivXLDqcfC9psBJpnvat8zYuw/edit?usp=sharing';
function init() {
Tabletop.init( { key: publicSpreadsheetUrl,
callback: showInfo,
parseNumbers: true,
postProcess: function(element) {
element["timestamp"] = element["day"] + " " + element["hour"]
}
});
}
function showInfo(data, tabletop) {
console.log(data);
}
window.addEventListener('DOMContentLoaded', init);
So far no matter what I put in postProcess: function doesn’t seem to work.
Many thanks for your help.