In an attempt to consolidate data, this program aims to transfer information from one spreadsheet to another. The process involves retrieving all files within a designated folder (all of which are spreadsheets), extracting values from a specific range, and storing them in an array. Subsequently, the program switches to another spreadsheet where it attempts to populate the first row with the array values. Finally, once the data is transferred, the original file is moved to a different location.
var uploadG = DriveApp.getFolderById('')
var moveToG = DriveApp.getFolderById('')
function obtainAndImportData(uploadFolder){
var internalFiles = uploadFolder.getFiles()
while (internalFiles.hasNext()){
var file = internalFiles.next()
var fileID = file.getId()
var copySheet = SpreadsheetApp.openById(fileID).getSheets()[0]
var Cvals = copySheet.getRange("C1:C").getValues()
var lastToValue = Cvals.filter(String).length-2
var Csheet = pasteSheet.getRange("C1:C").getValues()
var lastSheetToValue = Csheet.filter(String).length
var allRows = []
for (i = 0;i = lastToValue;i++){
allRows[i] = copySheet.getRange(`B${i+3}:P${i+3}`).getValues()
}
var rangeToUnify = pasteSheet.getRange(`B${lastSheetToValue+1}:P${lastSheetToValue + lastToValue + 1}`)
rangeToUnify.setValues(allRows)
file.moveto(moveToG)
}
}
Despite expectations, the execution of this program seems to remain incomplete. It fails to insert and move data without displaying any errors throughout the process.
Note: The program reads .xslx files, which are eventually converted to Google Spreadsheets upon upload to Google Drive. This conversion may be causing complications that are challenging to resolve.