A library used to generate a valid QGIS project out of a given XLSForm file.
Compatable with PyQt5, qgis 3.36+ and python 3.10+
Prerequisite: This library requires QGIS to be installed on your system, as it depends on
qgisandPyQtlibraries that are not available on PyPI. Install QGIS from qgis.org before proceeding.
Install the package from PyPI:
pip install xlsform2qgis
You can use the library by simply importing:
from xlsform2qgis.converter import XLSFormConverter
converter = XLSFormConverter("input_xlsform.xls")
converter.convert("output_qgis_directory")Or by running from the commandline:
uv run xlsform2qgis ./samples/service_rating.xlsx ./output/
- Clone the repository and enter it's directory:
git clone git@github.com:opengisch/xlsform2qgis.git
cd xlsform2qgis
- This repository uses the pre-commit project. Install it on this project.
pre-commit install
- This repository uses the uv project. Create a new environment.
uv venv
- Manually add the externally managed
PyQt5andqgislibraries to your environment:
ln -s /usr/lib/python3/dist-packages/qgis .venv/lib/python3.12/site-packages/
ln -s /usr/lib/python3/dist-packages/PyQt5 .venv/lib/python3.12/site-packages/
- OPTIONAL Add the
xlsform2qgislibrary system wide in all Python scripts as editable module. This will allow developingxlsform2qgisin parallel with other projects, such as theXLSFormConverter QGIS Plugin.
sudo uv pip install --system --break-system-packages --editable .
If you are using VS Code and want to debug test and debug the project, run:
uv run python3 -m debugpy --listen 5678 --wait-for-client ./src/xlsform2qgis/converter.py ./samples/service_rating.xlsx ./output/
To run all tests:
uv run pytest
To run a specific test:
uv run pytest -k test_converter