0

I have a google script to extract CSV files from sub labels in gmail. it works beautifully except that if there is anything in the "notes" column, it wraps it down to the next line and adds in extra cells, see the image on line 183.

I have tried using sheet.deleteColumn(11) but it only deletes what is in that cell, not what it sends to the next row. The notes column is automatically added to the CSV file before it comes to my inbox, so there's not much i can do to get it off of there. I included the script.

function import_TS_CSV_from_Gmail() {
  var threads = GmailApp.getUserLabelByName('VZ CKID G Script').getThreads();
  var first_thread = threads[0].getMessages()
  var last_thread = threads[threads.length - 1].getMessages();
  var last_thread_last_message = last_thread[last_thread.length - 1];
  var attachment = last_thread_last_message.getAttachments()[0];
  var sheet = SpreadsheetApp.openById('1ApVkvybqi0j1ItZbjhRly_7sAOvd-FKKw0BwPmRxaOg').getSheetByName('Data');
  var csvData = Utilities.parseCsv(attachment.getDataAsString(), ",");
  sheet.clearContents().clearFormats();
  sheet.getRange(1, 1, csvData.length, csvData[0].length).setValues(csvData);
}

CSV Google Script

Rubén
  • 34,714
  • 9
  • 70
  • 166
Cierra
  • 1
  • Remove the commas out of the notes – Cooper May 12 '22 at 16:08
  • to do that i would have to open the file from my email, then remove the commas, and then resend the email to myself and run the script... not very automated. – Cierra May 12 '22 at 16:12
  • Well maybe it's something else. The point is look at the the data and see what's causing the problem and figure out how you can remove it. We don't have the benefit of accessing the raw data like you do. – Cooper May 12 '22 at 16:22

0 Answers0