我正在处理一个工作表,该工作表将存储在google文件夹中的10个CSV文件组合到一个Google工作表中。我以前已经能够运行代码,但是我开始遇到很多基于时间的错误。我希望有人可以帮助简化以下代码。我知道我可以循环运行此程序,但是我认为这不会更快。
//Sets Sheets to variable
var AUG = DriveApp.getFilesByName("Set1.csv").next();
var Sep1 = DriveApp.getFilesByName("Set2.csv").next();
var Sep2 = DriveApp.getFilesByName("Set3.csv").next();
var Oct1 = DriveApp.getFilesByName("Set4.csv").next();
var Oct2 = DriveApp.getFilesByName("Set5.csv").next();
var Nov1 = DriveApp.getFilesByName("Set6.csv").next();
var Nov2 = DriveApp.getFilesByName("Set7.csv").next();
var Dec1 = DriveApp.getFilesByName("Set8.csv").next();
var Dec2 = DriveApp.getFilesByName("Set9.csv").next();
var Dec3 = DriveApp.getFilesByName("Set10.csv").next();
//Parse String
var csvAUG = Utilities.parseCsv(AUG.getBlob().getDataAsString());
var csvNov1 = Utilities.parseCsv(Nov1.getBlob().getDataAsString());
var csvNov2 = Utilities.parseCsv(Nov2.getBlob().getDataAsString());
var csvOct1 = Utilities.parseCsv(Oct1.getBlob().getDataAsString());
var csvOct2 = Utilities.parseCsv(Oct2.getBlob().getDataAsString());
var csvSep1 = Utilities.parseCsv(Sep1.getBlob().getDataAsString());
var csvSep2 = Utilities.parseCsv(Sep2.getBlob().getDataAsString());
var csvDec1 = Utilities.parseCsv(Dec1.getBlob().getDataAsString());
var csvDec2 = Utilities.parseCsv(Dec2.getBlob().getDataAsString());
var csvDec3 = Utilities.parseCsv(Dec3.getBlob().getDataAsString());
//Determine Lengths
var rowset1 = csvAUG.length
var rowset2 = rowset1+csvSep1.length;
var rowset3 = rowset2+csvSep2.length;
var rowset4 = rowset3+csvOct1.length;
var rowset5 = rowset4+csvOct2.length;
var rowset6 = rowset5+csvNov1.length;
var rowset7 = rowset6+csvNov2.length;
var rowset8 = rowset7+csvDec1.length;
var rowset9 = rowset8+csvDec2.length;
var rowset10 = rowset9+csvDec3.length;
var colset = csvAUG[0].length;
//Start Combines CSV's for Scores
ss.setActiveSheet(ss.getSheetByName("Raw Scores"));
var sheet = SpreadsheetApp.getActiveSheet();
sheet.clear();
sheet.getRange(1, 1, rowset1, colset).setValues(csvAUG);
sheet.getRange(1+rowset2, 1, csvSep1.length, colset).setValues(csvSep1);
sheet.getRange(1+rowset3, 1, csvSep2.length, colset).setValues(csvSep2);
sheet.getRange(1+rowset4, 1, csvOct1.length, colset).setValues(csvOct1);
sheet.getRange(1+rowset5, 1, csvOct2.length, colset).setValues(csvOct2);
sheet.getRange(1+rowset6, 1, csvNov1.length, colset).setValues(csvNov1);
sheet.getRange(1+rowset7, 1, csvNov2.length, colset).setValues(csvNov2);
sheet.getRange(1+rowset8, 1, csvDec1.length, colset).setValues(csvDec1);
sheet.getRange(1+rowset9, 1, csvDec2.length, colset).setValues(csvDec2);
sheet.getRange(1+rowset10, 1, csvDec3.length,colset).setValues(csvDec3);