Automate .xlsx modification or creation in an AI friendly space.
I created this project for my portfolio. I'm hoping to showcase my ability to write python code by connecting to a database, using APIs, processing files, etc.
Currently the flask app is used only to support a quick and simple UI to a single user locally and does not follow good practices in running a full scale web server.
At the same time, the reason I came up with the idea is that I have worked in the digital marketing space within Amazon Ads. Though I spent most my time with the APIs, I saw the need to automate a very wide variety of tasks, that all could probably be done easily with SQL queries outputting .xlsx files.
Many companies that don't have the budget for developing an application using Amazons APIs can benefit from this tool.
This is intended to be run locally and with one process at a time(for those thinking of gunicorn or something similar). This should not be run on a public server without being modified.
- Upload xlsx/xlsm/xltx/xltm files into your Postgres Database
- Query and output result into a .xlsx file, Google Sheet or very simple html table
That's it! Pretty simple but extremely powerful with the rise of AI. Since most people who don't understand Postgres can probably get ChatGPT, Claude, etc. to do what they want. This would allow most people to automate their data worksheet processes. Or learn SQL, it's easier than you might think.
Consider leaving a star.
If you have benefited from this project and/or would like to see more features. Consider supporting
- python 3.10 or above
- Postgres database
- Google how to get one on your Operation System
- Or buy one
pip install -r requirements.txtpython3 main.py
In depth video walkthrough here
- Download project
- Open terminal to project directory
- [Optional & HIGHLY RECOMMENDED] Set up python virtual environment
- [Help] Run the following commands inside the terminal with copy/paste
- install packages:
pip install -r requirements.txt(for errors, see below) - run server:
gunicorn --timeout 1200 -k gevent -b localhost:7777 main:app - open web browser to http://localhost:7777
- Ctrl + C in terminal to stop server
pip errors. Instead try:
python3 -m pip install -r requirements.txtpython -m pip install -r requirements.txt
- Input
id(Give this connection a unique name) - Input
Host - Input
User - Input
Password - Input
Database - Input or leave as is
Port
Don't have a database, user, etc.?
For Host get your databases ip address. If running on the same computer put localhost.
For User, Password, Database.
Connect to Postgres.
(For the following commands replace values my_database and my_user with useful names.)
Run create database my_database;
then create user my_user with password 'super-secret-password';
and finally ALTER DATABASE my_database OWNER TO my_user;
- If you have no button. See below for setting up credentials.
- Once you have credentials with the correct file name, you should see this button after refreshing the page.
- Select the database
- Fill the table name
- Upload a xlsx/xlsm/xltx/xltm file
- Select the sheet to upload
- Click
Upload!
- Write SQL query
- Click
Saveor Ctrl / Cmd + S - [Optional] Save Locally
- Click
Save As - Provide a unique "file" name
- Click
Save Asagain
- Click
This section is for advanced users
This will iterate through each row of the Sub-Query replacing sub-strings of keys(column names) wrapped in double braces in the Query string with the table values appending all the results together into a single table.
table test:
| a | b | c | ------------- | 1 | 2 | 3 | | 4 | 5 | 6 |
query: select '{{b}}' as foo;
sub-query: select * from test;
result table:
| foo | ------- | '2' | | '5' |
- A Google Cloud Account (free)
- Google API Credentials
json - Enabled Google Sheets API within same projects as credentials
We currently don't have screen shots presenting this process.
- you'll need a Google Cloud account. Don't worry it's free. Just go to https://cloud.google.com and use your Google Account.
- For the following step set
http://localhost:7777andhttp://127.0.0.1:7777as origin urls thenhttp://localhost:7777/authorize-google-sheets-callbackandhttp://127.0.0.1:7777/authorize-google-sheets-callbackas redirect urls. There should be inputs at the end of the next step to do this. - To get the credentials needed for follow Google's guide here, this stack overflow question may also be helpful.
- Once you have the credentials in a
.jsonformat rename it togoogle_credentials.jsonand place it inside the project folder - Enable the Google Sheets API within the same project here






