I have a Google Sheet which i want to import a CSV File stored in my drive.
this is my code:
function importCSVFromGoogleDrive() {
var file = DriveApp.getFilesByName("file.csv").next();
var csvData = Utilities.parseCsv(file.getBlob().getDataAsString());
var sheet = SpreadsheetApp.setActiveSheet(sheet.getSheetByName('TEST'))
sheet.getRange(1, 1, csvData.length, csvData[0].length).setValues(csvData);
}
I get error "TypeError: Cannot read property 'getSheetByName' of undefined". I would like to import my data of the CSV into the "TEST" Tab. How i can fix this?