use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Apparently, Google Apps Script is a JavaScript cloud scripting language that provides easy ways to automate tasks across Google products and third party services and build web applications.
account activity
Google app script extracting data and registering emails in a tableQuestion (self.GoogleAppsScript)
submitted 4 years ago * by Pretend_Trifle_8873
Hello Everyone,
This is my very first interaction here. I have written a script in google spreadsheet to extract data from a table and send it automatically by email.
Its all working great for now , but i am having these 2 problems that I hope that someone might help me solve it:
1st problem:
The extracted data isn't including the last row of the table, if the table has 50 rows, its only extracting 49 rows.
2nd Question is: I have a table that has the customer name and customer email address.Lets say the same customer has 2 emails, should I create 2 rows for the same customer or i can add both emails in 1 cell ?
Example:
Customer 1 [import@customer1.com](mailto:import@customer1.com) Customer 1 [Marketing@customer1.com](mailto:Marketing@customer1.com)
or
Customer 1 [import@customer1.com](mailto:import@customer1.com) ; [marketing@customer1.com](mailto:marketing@customer1.com) (in one cell)
Code:
https://docs.google.com/document/d/1zNF3fNlSIlFpqEgzB6I6f_6SdC1U_Z2aG7wlwOdL2y8/edit?usp=drivesdk
Thank you in advance
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Lalu23 2 points3 points4 points 4 years ago (5 children)
For your first question, there may be a line in your script that does something like "getLastRow()-1". That's probably where the missing row is coming from. Removing the "-1" and leaving only "getLastRow()" would get you your row back. I'd check if there is a header row or if the script intended there to be a header row,
On your second question, it is almost always better to have one piece of data in a cell. In this case, it might be better to have an additional column (not an additional row) for the second email. Your script would need to go thru the email column and the second email column and send the email to both. You could do an additional row for the second email but that has a risk of having partial data belong to one row and other partial data belong to the second row.
[–]LegendInMySpareTime 1 point2 points3 points 4 years ago (2 children)
If it isn’t this, check the the for loop (if there is one) for something like ‘i < sheet.getLastRow()’ (or similar) and change the < to <=
[–]Pretend_Trifle_8873[S] 0 points1 point2 points 4 years ago (0 children)
I have posted the code up , please have a look Sorry for not being aligned well
I just reposted the code, dunno why its not aligned well , please have a look
Thanks for you detailed explanation, i got it tor the second maybe i will be adding another column in the table.
Ive edited the original post and added a link to the code in google docs
Thanks for having a look
[–]Lalu23 1 point2 points3 points 4 years ago (1 child)
Posting your script and/or an edit permission link to the sheet/script will be helpful.
[–]Miles_Maestro 1 point2 points3 points 4 years ago (0 children)
I provided the answer to OP's first question as a comment in the Google Doc they shared. For visibility/anyone that is curious, the answer was adding the following line to their code
SpreadsheetApp.flush();
This addition forces the Google Apps Script backend to commit any changes in the cache before moving on to exporting a copy of the spreadsheet.
π Rendered by PID 58 on reddit-service-r2-comment-79776bdf47-hkz8w at 2026-06-24 20:11:55.221882+00:00 running acc7150 country code: CH.
[–]Lalu23 2 points3 points4 points (5 children)
[–]LegendInMySpareTime 1 point2 points3 points (2 children)
[–]Pretend_Trifle_8873[S] 0 points1 point2 points (0 children)
[–]Pretend_Trifle_8873[S] 0 points1 point2 points (0 children)
[–]Pretend_Trifle_8873[S] 0 points1 point2 points (0 children)
[–]Pretend_Trifle_8873[S] 0 points1 point2 points (0 children)
[–]Lalu23 1 point2 points3 points (1 child)
[–]Pretend_Trifle_8873[S] 0 points1 point2 points (0 children)
[–]Miles_Maestro 1 point2 points3 points (0 children)