Below is an approach that I use to sync data from SIMS.net (our MIS) to a Google Sheet. We do this for a fair number of things now to keep stuff up to date automatically.
The script I use to pull csv data into a sheet:
function copyfromcsv() {
var file = DriveApp.getFilesByName("yourcsvfile.csv").next();
var csvData = Utilities.parseCsv(file.getBlob().getDataAsString());
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh2 = ss.getSheetByName("sheettoimportto");
sh2.clear();
sh2.getRange(1, 1, csvData.length, csvData[0].length).setValues(csvData);
}
The script I use to pull csv data into a sheet:
function copyfromcsv() {
var file = DriveApp.getFilesByName("yourcsvfile.csv").next();
var csvData = Utilities.parseCsv(file.getBlob().getDataAsString());
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh2 = ss.getSheetByName("sheettoimportto");
sh2.clear();
sh2.getRange(1, 1, csvData.length, csvData[0].length).setValues(csvData);
}
Comments
Post a Comment