Skip to main content

SSB Altinn Form Tools

PyPI Status Python Version License

Documentation Tests Coverage Quality Gate Status

pre-commit Black Ruff Poetry

Features

  • Tools for automatically handling forms from Altinn3
    • Transforms the data to the standard schema for SSBs editing framework
    • Ingests the data using SQLAlchemy og Parquedit.

Requirements

  • TODO

Installation

You can install SSB Altinn Form Tools via pip from PyPI:

pip install ssb-altinn-form-tools

Example

See docs/documentation for further information. Walkthrough provides a deeper guide through the example and how everything works.

import logging

logging.basicConfig(
    level=logging.DEBUG,  # Set minimum log level
    format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
    force=True,
)

from sqlalchemy import create_engine
from ssb_altinn_form_tools.default_form_processor import DefaultFormProcessor
from ssb_altinn_form_tools.default_form_extractor import DefaultFormExtractor
from ssb_altinn_form_tools.sqlalchemy_storage_connector import (
    SqlAlchemyStorageConnector,
)

extractor = DefaultFormExtractor()

engine = engine = create_engine("sqlite:///./db.db", echo=False)
connector = SqlAlchemyStorageConnector(engine)
for form_number in ["RA0187", "RA0297", "RA0307", "RA0366", "RA0479", "RA0481", "RA0530", "RA0536", "RA0689", "RA0745", "RA0825"]:
    processor = DefaultFormProcessor(
        form_name=form_number,
        form_base_path=f"/home/onyxia/work/ssb-altinn-form-tools/tests/testdata/{form_number}",
        extractor=extractor,
        connector=connector,
        alias_mapping={"omsVirksomhetPerioden": "omsetning"},
    )
    processor.process_new_forms()

from sqlalchemy import text

with engine.connect() as conn:
    tables = conn.execute(text("SELECT name FROM sqlite_master WHERE type='table';")).fetchall()
    print("Tables:", tables)

with engine.connect() as conn:
    rows = conn.execute(text("SELECT * FROM enheter LIMIT 10;")).mappings().all()
    for row in rows:
        print(dict(row))

Usage

Please see the Reference Guide for details.

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

License

Distributed under the terms of the MIT license, SSB Altinn Form Tools is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Credits

This project was generated from Statistics Norway's SSB PyPI Template.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ssb_altinn_form_tools-0.0.9.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ssb_altinn_form_tools-0.0.9-py3-none-any.whl (35.9 kB view details)

Uploaded Python 3

File details

Details for the file ssb_altinn_form_tools-0.0.9.tar.gz.

File metadata

  • Download URL: ssb_altinn_form_tools-0.0.9.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for ssb_altinn_form_tools-0.0.9.tar.gz
Algorithm Hash digest
SHA256 4fd29e73dd6426ca23c40f96790338bbd029d70cc40bc14574f7604846d3e9c1
MD5 3ced6ea15913542206ddd7af10a60762
BLAKE2b-256 51b0f202faa342ba624ef4cb19f2c01a25511826e2cfd3bc4954131a00188f49

See more details on using hashes here.

Provenance

The following attestation bundles were made for ssb_altinn_form_tools-0.0.9.tar.gz:

Publisher: release.yml on statisticsnorway/ssb-altinn-form-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ssb_altinn_form_tools-0.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for ssb_altinn_form_tools-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 58e6f997e0bde279f0480a95e96cffd99487de76cce2f9155a7a9990e79b1d5a
MD5 4cd97635d3be68be7b2c391b1eee6d03
BLAKE2b-256 63ef7d8385d0dd50408c8319b0c10e148f63f67db4853ed010ea64b1b64cb252

See more details on using hashes here.

Provenance

The following attestation bundles were made for ssb_altinn_form_tools-0.0.9-py3-none-any.whl:

Publisher: release.yml on statisticsnorway/ssb-altinn-form-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.0.9 This release

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page