Toolkit for using spreadsheets to create and modify RapidPro flows
Project description
RapidPro Flow Toolkit
Toolkit for using spreadsheets to create and modify RapidPro flows.
Quickstart
pip install rpft
rpft --help
Command Line Interface (CLI)
The CLI allows spreadsheets in various formats to be converted to RapidPro flows in JSON format. Full details of the available options can be found via the help feature:
rpft --help
Below is a concrete example of a valid execution of the command line tool. The line breaks are merely for improving readability; the command would also be valid on a single line.
rpft create_flows \
--output flows.json \
--datamodels=tests.input.example1.nestedmodel \
--format=csv \
src/rpft/tests/input/example1/content_index.csv
Using the toolkit in other Python projects
- Add the package
rpft
as a dependency of your project e.g. in requirements.txt or pyproject.toml - Import the
create_flows
function - Call
create_flows
to convert spreadsheets to flows
from rpft.converters import create_flows
sheets = ["sheet1.csv", "sheet2.csv"]
create_flows(
sheets, "flows.json", "csv", data_models="your_project.models"
)
It should be noted that this project is still considered beta software that may change significantly at any time.
RapidPro flow spreadsheet format
The expected contents of the input spreadsheets is documented separately.
Processing Google Sheets
It is possible to read in spreadsheets via the Google Sheets API by specifying --format=google_sheets
on the command line. Spreadsheets must be in the Google Sheets format rather than XLSX, CSV, etc.
Instead of specifying paths to individual spreadsheets on your local filesystem, you must supply the IDs of the Sheets you want to process. The ID can be extracted from the URL of the Sheet i.e. docs.google.com/spreadsheets/d/ID/edit.
The toolkit will need to authenticate with the Google Sheets API and be authorized to access your spreadsheets. Two methods for doing this are supported.
- OAuth 2.0 for installed applications: for cases where human interaction is possible e.g. when using the CLI
- Service accounts: for cases where interaction is not possible or desired e.g. in automated pipelines
Installed applications
Follow the steps in the setup your environment section of the Google Sheets quickstart for Python.
Once you have a credentials.json
file in your current working directory, the toolkit will automatically use it to authenticate whenever you use the toolkit. The refresh token (token.json
) will be saved automatically in the current working directory so that it is not necessary to go through the full authentication process every time.
Service accounts
Follow the steps in the creating a service account section to obtain a service account key. The toolkit will accept the key as an environment variable called CREDENTIALS
.
export CREDENTIALS=$(cat service-account-key.json)
rpft ...
Development
For instructions on how to set up your development environment for developing the toolkit, see the development page.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file rpft-1.0.1.tar.gz
.
File metadata
- Download URL: rpft-1.0.1.tar.gz
- Upload date:
- Size: 71.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86dcff3cc09025f0932800013d825952e204a33a25c0daa4226c5cb615499ebe |
|
MD5 | b6b723b50070683e01ea719765fed482 |
|
BLAKE2b-256 | 76363dc9c87fb9c20c06728d3cfc0f7a1df2044fdbd9756052cc21a7631a77f0 |
File details
Details for the file rpft-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: rpft-1.0.1-py3-none-any.whl
- Upload date:
- Size: 58.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 117099773b35fc8f62adffa910557d45fe75b22c437e36467312f90b28284c44 |
|
MD5 | bce1ce4c94893dc0362d447d0e905544 |
|
BLAKE2b-256 | 1b1eceb9c7ae67965c8abc7eb9f0ca84fd2812b9d7e4d0941522809903f56913 |