Skip to main content

SSB Altinn Python

Project description

SSB Altinn Python

PyPI Status Python Version License

Read the documentation at https://ssb-altinn-python.readthedocs.io/ Tests Codecov

pre-commit Black

Features

This is work-in-progress Python-package for dealing with xml-data from Altinn3.

from altinn import FileInfo, ParseSingleXml

file = "gs://ssb-prod-dapla-felles-data-delt/altinn3/form_dc551844cd74.xml"

# Create an instance of FileInfo
form = FileInfo(file)

# Create an instance of ParseSingleXml
form_content = ParseSingleXml(file)

# Get file filename without '.xml'-postfix
form.filename()
# Returns: 'form_dc551844cd74'

# Print a nicely formatted version of the file
form.pretty_print()

# Print an unformatted version of the file. Does not require the file to be parseable by an xml-library. Useful for inspecting unvalid xml-files.
form.print()

# Check if xml-file is valid. Useful to inspect xml-files with formal errors in the xml-schema.
form.validate()
# Returns True og False

# Get a dictionary representation of the contents of the file
form_content.to_dict()

# Get a Pandas Dataframe representation of the contents of the file
form_content.to_dataframe()

Requirements

  • dapla-toolbelt >=1.6.2,<2.0.0
  • defusedxml >=0.7.1,<0.8.0
  • pytest >=7.2.2,<8.0.0

Installation

You can install SSB Altinn Python via [poetry] from PyPI:

poetry add ssb-altinn-python

To install this in the Jupyter-environment on Dapla, where it is ment to be used, it is required to install it in an virtual environment. It is recommended to do this in an ssb-project where the preferred tool is poetry.

Usage

Please see the Command-line Reference 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 Python 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 @cjolowicz's Hypermodern Python Cookiecutter template.

Project details


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_python-0.2.6.tar.gz (5.8 kB view hashes)

Uploaded Source

Built Distribution

ssb_altinn_python-0.2.6-py3-none-any.whl (7.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page