What happens is that every day I receive an email with an attached report. This attachment is zipped (.zip), and inside this zip has a CSV file.
I need this zip to be converted to CSV and that this CSV will automatically go from my email (gmail) to the google worksheet on a specific page. I made a script, but I'm doubtful where I'm getting lost. It says that the argument is invalid in line 10 (var extracted ...)
function getCSV() {
var myLabel = GmailApp.getUserLabelByName('Relatórios X');
var threads = myLabel.getThreads(0,1);
var msgs = GmailApp.getMessagesForThreads(threads);
var attachments = msgs[0][0].getAttachments();
var csv = attachments[0];
var extracted = Utilities.unzip(csv);
var string = extracted[0].getDataAsString();
var data = Utilities.parseCsv(string);
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Relatório_aqui");
sheet.clearContents();
var range = sheet.getRange(1,1, data.length,data[0].length);
range.setValues(data);
}