Skip to main content

ADIS

A python package for parsing and creating ADIS (Agricultural Data Interchange Syntax) files.

This parser supports Class A ADIS format.

ADIS Standardization document

Wikipedia artice (unfortunately only available in german)

Installation

pip install adis

Examples

Parse an ADIS file and turn it to JSON

# example_adis_to_json.py
from adis import Adis

adis = Adis.parse_from_file("sample.ads")
generated_json = adis.to_json()

print(generated_json)

Prettyprinted output:

[
    {
        "990001": {
            "definitions": [
                {
                    "item_number": "00000000",
                    "field_size": 20,
                    "decimal_digits": 0
                },
                {
                    "item_number": "00000001",
                    "field_size": 9,
                    "decimal_digits": 6
                },
                {
                    "item_number": "00000002",
                    "field_size": 10,
                    "decimal_digits": 0
                }
            ],
            "data": [
                {
                    "00000000": "Euler number",
                    "00000001": 2.718281,
                    "00000002": null
                },
                {
                    "00000000": "Pi",
                    "00000001": 3.141592,
                    "00000002": null
                },
                {
                    "00000000": "Gravity on Earth",
                    "00000001": 9.81,
                    "00000002": "ms^(-2)"
                }
            ],
            "status": "H"
        },
        "990002": {
            "definitions": [
                {
                    "item_number": "00000008",
                    "field_size": 10,
                    "decimal_digits": 0
                },
                {
                    "item_number": "00000009",
                    "field_size": 10,
                    "decimal_digits": 0
                }
            ],
            "data": [
                {
                    "00000008": "abc",
                    "00000009": "xyz"
                },
                {
                    "00000008": "def",
                    "00000009": "uvw"
                }
            ],
            "status": "N"
        }
    },
    {
        "990001": {
            "definitions": [
                {
                    "item_number": "00000006",
                    "field_size": 10,
                    "decimal_digits": 0
                },
                {
                    "item_number": "00000007",
                    "field_size": 5,
                    "decimal_digits": 2
                }
            ],
            "data": [
                {
                    "00000006": "1",
                    "00000007": 1.23
                },
                {
                    "00000006": "2"
                }
            ],
            "status": "H"
        }
    }
]

Turn a JSON file to ADIS

# example_json_to_adis.py
from adis import Adis

adis = Adis.from_json_file("sample.json")
generated_adis_text = adis.dumps()

print(generated_adis_text)

Output:

DH990001000000002000000000109600000002100
VH990001Euler number          2718281??????????
VH990001Pi                    3141592??????????
VH990001Gravity on Earth      9810000ms^(-2)   
DN9900020000000810000000009100
VN990002abc       xyz       
VN990002def       uvw       
EN
DH9900010000000610000000007052
VH990001         1  123
VH990001         2|||||
ZN

About the ADIS format

Each physical file can contain multiple logical ADIS files, these are represented by objects of the type AdisFile. Each of those logical ADIS files contains one or multiple blocks, these are represented by objects of the type AdisBlock. Each block consists of the definitions for the fields (list of objects of type AdisFieldDefinition) and one or multiple data rows (list of list of AdisValue).

Documentation

This documentation only contains methods that are inteded to be used by the user. Take a look at the docstrings for more information about methods.

Adis

Static methods:

  • parse(text): Creates an Adis object from a text that's in the ADIS format
  • parse_from_file(path_to_file): Creates an Adis object from an ADIS file
  • from_json(json_text): Create an Adis object from a json text
  • from_json_file(path_to_json_file): Create an Adis object from a json file

Normal methods:

  • __init__(adis_files): Creates an Adis object from a list of AdisFiles
  • to_json(strip_string_values=True): Creates a json text containing the files, definitions and data
  • dumps(): Creates a text in the ADIS format
  • get_files(): Returns a list of AdisFiles

AdisFile

Normal methods:

  • __init__(blocks): Creates an AdisFile from a list of AdisBlocks
  • get_blocks(): Returns a list of AdisBlocks

AdisBlock

Normal methods:

  • __init__(entity_number, status, field_definitions, data_rows): Creates an AdisBlock
  • get_entity_number(): Returns the entity number of this AdisBlock
  • get_field_definitions(): Returns the field definitions as list of AdisFieldDefinitions
  • get_data_rows(): Returns the data rows as list. Each data row is a list of AdisValues

AdisFieldDefinition

Normal methods:

  • __init__(item_number, field_size, decimal_digits): Creates an AdisFieldDefinition
  • get_item_number(): Returns the item number
  • get_field_size(): Returns the field size
  • get_decimal_digits(): Returns the number of decimal digits

AdisValue

Static flags:

  • strip_string_values: String values that are returned by to_dict() will be stripped if this flag is set.

Normal methods:

  • __init__(item_number, value): Creates an AdisValue
  • to_dict(): Returns a dict containing the item number and value of this AdisValue

Metadata

Release files for adis 1.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 adis 1.0.1
File Size Uploaded Provenance
adis-1.0.1.tar.gz 14.2 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 29.3 kB

Release files / adis-1.0.1.tar.gz

Download URL adis-1.0.1.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7afcaabf32bdfddd618bfaff3f54d7e760396033bd828b7ed876b33eb263edab
BLAKE2b-256 checksum
How to use checksums
2d884914ff73b8a5433fae109ba494664d492e703e5bfbc14b2ca4da0bfea480
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release files / adis-1.0.1-py3-none-any.whl

Download URL adis-1.0.1-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9883f923e3241b8450b50962eacdf65554feeda5c698b1d80ace09f2838a327
BLAKE2b-256 checksum
How to use checksums
f3164bf672d3ea05ef84b79ad438105876e16fcf3c221cdfda630d8f5f5b6c12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Security for adis 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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