Google Script
I wanted to learn a little about Google Script. I discovered a site that has the vocabulary list from Latina Christiana I in a table in HTML. I was pleasantly surprised that this pasted nicely into a Google spreadsheet.
But the first column had extra stuff in it that I didn’t want in that column. Gee, I thought, wouldn’t it be nice to be able to just run a simple regular expression on that column to remove everything after the comma?
So yes, it is possible and really not very difficult to do. And here is my solution:
function stripAfterComma() {
var range = SpreadsheetApp.getActiveRange();
var values = range.getValues();
var results = [];
for( j in values ){
var row = [];
for( i in values[j] ){
var new_value = values[j][i].match( /^[^,]*/ )[0];
row.push(new_value);
}
results.push(row);
}
range.setValues( results );
}
And Voila my spreadsheet can now be pasted into Quizlet and used to learn those vocabulary words. Have fun with the quiz.
Advertisement
Categories: Programming
Recent Comments