This project is an API catered to google sheet via google apps script. It handles common and repetitive formatting tasks thats usually in demand for demographic type data.
Install python 3+ and pip into your device. After pip is installed in your computer, we need flask to continue, so in your terminal run:
pip install flask
python manage.py
In order for google apps script to request to the running application, the local endpoint needs to be forwarded and exposed to the web using . Follow the intructions until usage and run:
ngrok http 5000
Copy the "Forwarding" url, ex: https://7d0b-173-52-201-90.ngrok.io, to use in the next step.
Log in to your google account and navigate to google sheets and in a new sheet fill one column with random first names with a column title of "Full Name".
Go to the top tool bar > Extensions > AppSheet > Create an app.
Create a new sheet and put the following algorithms in it:
function callServer(columns, data, job) {
let draft = {
columns,
data
};
const URL = <YOUR_GENERATED_NGROK_URL>+job;
let options = {
method: "POST",
contentType: "application/json",
headers: {
"Authorization": "bearer " + ScriptApp.getOAuthToken()
},
payload: JSON.stringify(draft),
muteHttpExceptions: true
};
return urlFetchApp.fetch(URL, options);
}
function getGuessedGender() {
const cs = getCurrentSheet();
const res = JSON.parse(callServer(["first_name"], cs.rows, "genderize"));
cs.sheet.get(1, 1, res.length, res[0].length).setValues(res);
}
YOUR_GENERATED_NGROK_URL
is where you can paste the ngrok url, then run "getGuessedGender" as the main point of starting the script.
- PyPi (https://pypi.org/project/pip/)
- Flask (https://flask.palletsprojects.com/en/2.2.x/)
- Ngrok (https://ngrok.com/)
- Google Apps Script (https://developers.google.com/apps-script/guides/sheets/functions)
- JavaScript Fetch (https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch)