I am trying to import only few columns from a CSV in a google sheet. My CSV is huge (26k lines) and I only need 4 columns of the 32 that are imported. The following script (that I found in the forum) is used to import the CSV into GoogleSheet:
function importReport() {
var threads = GmailApp.search('label:stock_fastmag subject:"Rapport de commande - article detail - TOTAL"');
var message = threads[0].getMessages()[0];
var attachment = message.getAttachments()[0];
attachment.setContentType('text/csv');
// Is the attachment a CSV file
if (attachment.getContentType() === "text/csv") {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Reliquat_commandes_clients");
var csvData = Utilities.parseCsv(attachment.getDataAsString(), ";");
// Remember to clear the content of the sheet before importing new data
sheet.clearContents().clearFormats();
sheet.getRange(1, 1, csvData.length, csvData[0].length).setValues(csvData);
}
}
The problem is that as the script can not run entirely, the authorized execution time is too short. Do you think that if I import only some columns of the CSV it should make it quicker?