Archiving data in google sheets - multiple rows and multiple columns - google-sheets

Hello everyone I am attempting to modify a script that I found in this post (Archiving in Google Spreadsheets with Date Using Apps Script). The goal is to set it up on a time trigger/button to a specific range of cells into a sheet within the same workbook. When it is archived it should overwrite the previously archived data within the range of cells on the "archive" sheet. I have played with this script with this suggested script from this post and removed the "delete" and "priorities" components of the action, but am still having problems getting it to simply overwrite what is already there. I will continue to work with it withing my limited knowledge as I continue to learn, but would greatly appreciate any help or tips. Or if their is a preexisting code that would serve the purpose that I have missed I would love to hear about it.
Thank you for any insight you can provide and for all the help in the past.
*and thanks to Jad and the User1786546 for the original posting.

I had a quick look at the script post.
If you wanted it to delete the archive data before writing to it, you might need to clear the contents of the sheet first before writing the data.
targetsheet.clearContent();
This will clear the whole target sheet, (the target sheet is a variable in the script you linked to, this name can be changed), including column headers.
If this is undesirable, then you may wish to use
getRange().clearContent();
Please see this link for more info.
https://developers.google.com/apps-script/reference/spreadsheet/range#clearContent()
If you still need further help, try sharing a dummy spreadsheet, with realistic data and sheets.

Related

Solved: Extract date from my Substack webpage to Google Sheets

longtime lurker, first-time poster. I usually solve my issues & upvote without needing to post, but I've been stumped all weekend!
Edit: Erik solved it:
I was looking for an answer to extract the "datePublished" or "dateModified" from a Substack article in a Google Sheet.
Goal: This will tell me when it was the last date/time I updated, for example, my PS5 restock guide, my Walmart PS5 restock guide, etc. If it's too stale, I try to add relevant information. Having it in Google Sheets makes it streamlined as there are dozens of guides.
Test Google Sheet:
https://docs.google.com/spreadsheets/d/1hLBFMWCTc2hpC-1C8Sxd5OVREdNHTVTtrJsAAU5Jl94/edit#gid=0
I've done this before for other sites I've worked at, but there appears to be no date in the meta data on Substack :/ (I could be wrong, as I'm no expert at reading XPATH)
I do see this in the body for the linked example:
<time datetime="2022-07-29T11:52:00.000Z">Jul 29</time>
I've been trying things like this (where E17 is where I put the article URL in Google Sheets) to no effect.
=REGEXEXTRACT(IMPORTXML(E17, "//time[#datetime='datePublished']/#content"), "(.+)T")
I've been mostly working off of this StackOverflow solution, but I haven't been able to apply the same finding to Substack's formatting.
If you want to grab it directly using a Google Sheets formula, this should work for you:
=ArrayFormula(IFERROR(VLOOKUP("*",FLATTEN(IFERROR(REGEXEXTRACT(IMPORTXML("https://www.theshortcut.com/p/ps5-restock","//div[2]"),"Swider(.?.?.?.?\d\d{1}[hrago\s]*)"))),1,FALSE),"???"))
To set realistic expectations, I usually can't invest this much time into working out such a solution on this forum. But I'm on vacation at the moment and filling time while my guest is otherwise occupied.
One further note: this is specific to the two sites you gave as examples. It will only work for sites where the second <div> holds this information and only where the data exists as strings exactly like those found on these two sites (including the poster's last name as "Swider").
ADDENDUM:
Looking at this further, did you try simply the following?
=IMPORTXML(C2, "//time")
(assuming your URL is in C2, etc.)
This seems to work for me, given that it appears the date/time data you want is contained within the first <time> element on the web page.

How do I import a Google sheet in a chrome extension project?

I wish to enhance an existing web page by adding statistics that can be regularly fed by a large amount of people.
I chose to use Google Sheets to retrieve the data so that anyone can access the tables and make their addition but I have no clue of how to display the sheet's results in the concerned web page.
In my case, I'm editing the webpage's text from Javascript.
I thougth of two tools that might help:
Importing the google sheet in Javascript (I can't find how to do that, an alternative would be welcome if not possible)
Importing the google sheet in Python and then exporting its results as an internal .txt file which I should be able to read with Javascript but that would require the .txt file to be updated every now and then.
Could you guys lend me a hand in how to do this?
Thanks in advance!

Google Sheet data update before opening document

Is there a way to update spreadsheet data automatically before opening the spreadsheet ?
Let's develop a little bit. In a main Spreadsheet I'm doing some IMPORTRANGE to get data from 2 other Spreadsheets (these data are refreshed twice a day). Then I used the imported data to present a kind of summary / dashboard with some complex formulas.
When I open the main spreadsheet, it takes looooong time to update.
I noticed that this long time is driven by the change of imported data.
Is there a way to do this update offline and not trigger a calculation when opening the document ?
Hope I'm clear, don't hesitate to contact me for further clarification.
I think this can be done with a script, but this is not my area (I found a solution on an external link, but don't want to post it here):
function myFunction() {
SpreadsheetApp.getActive().getRange('A1').setValue('IMPORTRANGE('https://docs.google.com/spreadsheets/d/abcd123abcd123', 'sheet1!A:B')')
}
Then within the current project's triggers, select a 'time-driven' event source based on minutes of your choice.

Zapier pull Word Count of a given document and connect it with Google Sheets

Here is what I need help with:
I need to connect the Word Count of a given document with Google Sheets.
I tried this with the current settings that Zapier has, but apparently it doesn't pull the data from the Word Count.
I am struggling to find a solution for this. And I am wondering whether is just impossible with this platform because the data is not pulled, or there is something it could be done about it.
To give you some context, as why I would need this. It is because I run a ghostwriting company and I would need to track the progress of the projects. Having that information updating periodically in Google Sheets would be really helpful.
Thank you
David here, from the Zapier Platform team.
I took a look and it seems like we're not pulling that right now. We've got an open feature request for the content. If you'd like, I can add your email to that request and you'll get notified if/when it gets fixed!

Why does the "continue" command appear on some google sheets but not others

I have two google sheets. In one I have created a function and want to put it into the other. In the first sheet it works great and has no issues, in the second sheet it seems to automatically insert the "continue(1,2,) etc.
The code I have, which works in the first sheet is:
=SPLIT(ADDTOTAL(SORT('REPORT LOOKUP'!F1:F35)),",")
(Addtotal is a custom script) but in the second sheet where it seems to autoinsert the "continue" it has duplicates and additional columns.
Anyone know what the issue woudl be, how I can turn off the continue if I need to?
Thanks
Sigh- much pain could have been avoided if I had checked dates the sheets were created. The difference is that the one sheet is a new google doc, the other old. The new sheets do not behave the same way as the old, they no longer use the "continue" function but just post the data.

Resources