About a year ago, I came here looking for the right direction to take with a project I was starting from scratch. Thanks to everyone here, I am proud to say I’ve moved through what was needed to get to this point and am seeking help again.
I went from running a bunch of calculations in Excel to doing them in a combination of Python and Google Sheets (because it was easiest to keep constantly connected to the internet). I know that Sheets is a placeholder, and I’m assuming I need to replace that with SQL (let me know if I’m right or wrong there).
I’m now trying to make a frontend that will spare me the trouble of logging into my computer remotely and running my Python script. Here’s where I’m stuck. Because I’d like to eventually make an iPhone app, I feel I should learn Swift. If I do, would I only be using it to execute the Python script, or would it be eventually replacing it?
Between now and the time it would take to learn Swift, what’s the other alternative to make a frontend that can run the Python script remotely? I figure servers come into play somewhere here, but I’m lost with that. Do I need to host the script somewhere? Does it go on GitHub?
In the end, I wanted to cut Excel out and have everything done remotely. I’ve solved the first part (although Sheets is not REALLY cutting out Excel, so I should say “local instance of Excel”), but now trying to make this usable in a number of different circumstances. And make it more professional.
Thanks in advance!
Its hard to give much advice without know more about the project. Here’s my questions:
- How does Google Sheets work with Python?
- Have you looked into app script?
- How do you “run” the python script?
- What does the python script do with the sheet? (does it just read data, does it write data?)
Finally I’d like to recommend a few things that I’m pretty sure you will need.
- A place to host and run your python code, so AWS, Google Coud, or MS cloud are all great choices to “run” your code from anywhere at any-time. Each has lots of options of how todo this, but this brings me to the code itself.
- Regardless of the “front-end”, you need to be able to interact with your Python code, unless its just “ran” (no arguments, inputs, anything) it needs to provide an API that any front-end can call from anywhere on the internet. This is where web-frameworks/web-apis for python come in. Something like Flask would allow your python app to interface with the internet, provide authentication and security.(you don’t any one to run the script right?)
- Once the python logic is setup on the server, you can setup any front-end, it could be a website/app/another python script you manually run, to interface with whats in the server. Now that its on a server, it can be called anywhere at any time for anything.
Again, its hard to provide more details or advice without know more about the use-case
Thanks so much for the response! Let me work backward in responding, because those 3 points at the end for what you think I will need really answered a lot…
"A place to host and run your python code"
That’s exactly what I’m trying to figure out. I will look more into those 3 (I’ve tinkered with AWS and Google Cloud to no avail in the past), but it’s a good start knowing what I need.
"it needs to provide an API that any front-end can call from anywhere on the internet"
I started taking a class in Flask awhile ago, but I didn’t realize that would be applied here. I would say that I could get away with just running my script without adding any inputs to it, but I know that wouldn’t last forever. I might as well future-proof it. So, if I’m understanding correctly, I would basically be turning my current script into an API. Is that right?
"Once the python logic is setup on the server"
I’m sure this will be a lot harder than it sounds, but that’s exactly what I’m trying to accomplish.
Now, to answer the other questions:
- I use Sheets to store large Python dataframes, and then pull down that information to Python where I need it. I probably could cut out Sheets entirely for that area of the script, but I feel it’s semi-useful in checking the data before I calculate.
- The little time I’ve spent looking into Google App Script (assuming that’s what you mean) in the past has been more frustrating than productive. If that’s the way I have to go, then I’ll try harder, but I can’t connect-the-dots in my mind as to what to do with it.
- I’ve just been executing the script in Spyder. It does have a few text-based inputs that are needed, so I guess that negates what I wrote earlier about just running it remotely, but I assumed I could program around that. I just don’t want to. So, I guess I’m really asking how to “run and send a few inputs to” the script (which is what we are discussing, anyway).
- Python reads and writes to Sheets in the same run. It’s updating information in one spot, and then pulling new information elsewhere. So far, it’s worked ok, but I’m pretty convinced that has to become SQL in the future.
Thanks again for the help!