Skip to main content

xlsform-converter (xlsconv)

xlsform-converter converts surveys defined via the XLSForm standard into Django models and configuration. This makes it possible to re-use the powerful form building tools provided by the Open Data Kit ecosystem, while leveraging Django's robust support for relational databases like PostgreSQL.

xlsform-converter is designed to facilitate the rapid development of offline-capable data collection apps via the wq framework. The ultimate goal is to provide full compatibility with the form authoring tools provided by ODK and KoboToolbox (etc.). Note that this is not the same as full XForm compatibility: the client and server components of wq (wq.app and wq.db) use a JSON-based REST API to exchange data and are not directly compatible with their ODK Analogues (ODK Collect and ODK Aggregate, respectively).

For the database itself, the key distinction from other XLSForm tools (including those powered by Django, like KoboToolbox) is that xlsform-converter converts the xlsform fields directly into a Django model definition, rather than representing the entire XForm standard within Django. This means that each row in an XLSForm "survey" tab is mapped to (usually) a single column in a simple relational database table. Repeat questions are handled by creating a second model with a ForeignKey to the parent survey model.

For a more thorough comparison of XLSForm tools, see https://wq.io/overview/survey123-vs-kobotoolbox-vs-wq.

xlsform-converter also supports a couple of additional "constraints" that are not part of the XLSForm standard:

  • wq:ForeignKey('app.ModelName'): Create a foreign key to an existing Django model (presumably not defined in the spreadsheet). This is effectively a more relational version of select_one_external.
  • wq:initial(3): Very similar to repeat_count, but only set for new records.
  • wq:length(5): Text field maximum length (similar to a string-length constraint)

Latest PyPI Release Release Notes License GitHub Stars GitHub Forks GitHub Issues

Tests Python Support

Included Templates

xlsform-converter uses ASTs and templates to generate the following Django/wq project files from a given XLSForm (for example, this file).

Django Apps

Usage

If you are using wq, you may be interested in wq.create, which uses xlsconv internally for the wq addform command. Otherwise, you can use xlsconv directly with the following command-line API:

# Recommended: create virtual environment
# python3 -m venv venv
# . venv/bin/activate

# Install xlsconv
pip install xlsconv

# Use the default models.py template
xls2django my-odk-survey.xls > myapp/models.py

# Use the rest.py template (or admin.py, or serializers.py)
xls2django my-odk-survey.xls rest > myapp/models.py

Metadata

Release files for xlsconv 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xlsconv 2.0.1
File Size Uploaded
xlsconv-2.0.1.tar.gz 20.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xlsconv 2.0.1
File Interpreter ABI Platform
xlsconv-2.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 31.3 kB

Release files / xlsconv-2.0.1.tar.gz

Download URL xlsconv-2.0.1.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1b5e940c500dd88b54b67dd76c60c115205ab58fba856ee032ec662a9f250839
BLAKE2b-256 checksum
How to use checksums
aa0abf4fd96748543da9d4631c6f170f489867f7dc3857cbf6fc0714bfea018a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / xlsconv-2.0.1-py3-none-any.whl

Download URL xlsconv-2.0.1-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a4c5e67ba3987634ebe669b0e8d235920670309b8b1ec5cbb85c753a40676fc1
BLAKE2b-256 checksum
How to use checksums
0772a23bbeb970917bde0aefae4f165e9ba87e0fe3fe0083a9d77eec6b9fed54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 release files

2.0.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

1 release file

1.0.0

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page