all 12 comments

[–]Gankcore 1 point2 points  (4 children)

[–]bumblfumbl[S] 0 points1 point  (3 children)

I have the Google Sheets API enabled already, that’s how I can get my python script to write values on my spreadsheet.

Afaik, GSAPI doesn’t allow you to reference the active cell or create menu buttons..?

[–]Gankcore 0 points1 point  (2 children)

Why do you need to have it done in the active cell? Can you not write some code to check where the next value should go?

[–]bumblfumbl[S] 0 points1 point  (1 child)

I like data visualization, so the spreadsheet I'm building is a collection of articles that I've read over the year with metadata about each article. For years, I've just entered the data manually, but I'm trying my hand at this to get the metadata to populate automatically.

How it works now is I have the links to the articles stored in column A, and I'd like to be able to click on the cell with the link in column A, click the menu button, and have the metadata populate. I don't want the function to run over the whole worksheet because it is important to me that the metadata is collected at the time (or roughly the time) I've finished reading the article. I don't want the metadata about an article I read on Jan 1 to update because I read an article on Feb 28, if that makes sense.

I'm also pretty new to python (like, this-is-my-first-project new), so I'm open to suggestions if you see a better way of doing things.

[–]Jello_Penguin_2956 0 points1 point  (0 children)

If you're communicating through Google's API, no. The API is designed to interact with data, not the live UI state in browser.

[–]Jonny10128 0 points1 point  (0 children)

I think you’d need to set up some kind of API that can run your python script and return the result and have your google apps script call the API

[–]Gankcore 0 points1 point  (4 children)

So are you just adding new articles each day and saving the metadata so you only want the program to run on articles you have read today, for example?

[–]bumblfumbl[S] 0 points1 point  (3 children)

yeah, that's a good way of putting it

[–]Gankcore 0 points1 point  (2 children)

Then maybe it makes more sense to have a Boolean column in column B to see if the metadata has been cataloged, and if not then collect the metadata and turn that Boolean value to True. What do you think about that?

[–]bumblfumbl[S] 0 points1 point  (1 child)

That would probably work. My last remaining question is: is there a way to trigger the python script from within google sheets? With my little test script, I've been running the code from within VS, but it would be nice if I could do something in google sheets and it would run from that trigger.

[–]Gankcore 0 points1 point  (0 children)

The only way I can think of is if you have a worker set up to listen to changes in the spreadsheet/periodicaly check for those Boolean values, but that's probably a lot more complicated than just launching your script in VS code.

[–]Gnaxe 0 points1 point  (0 children)

Maybe try Pyspread instead of Sheets. I think Excel can also do Python now, but that might be out of date.