This tutorial solves this issue about how to parse a text document open by an Id and put the output into a Spreadsheet.
The input text from the text document must have four signed number delimited with a comma like as regular expression variable named r from source code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | function write() { var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); var doc = DocumentApp.openById('123xyzTimp\oOBb|hH...'); var text = doc.getBody().getText(); var result = []; var r = /[+-]?\d+,[+-]?\d+,[+-]?\d+,[+-]?\d+/g while ((res = r.exec(text)) !== null) { //result.push([res[0]].toString()); result.push([res[0]].toString().split(",")); Logger.log(result); } //ss.getRange(row, column, numRows, numColumns) ss.getRange(ss.getLastRow() + 1, 1, result.length, 4).setValues(result); } |