Skip to main content

Convert ADIF ADI/ADX content to dictionary and vice versa

Project description

PyADIF-File

PyPI Package Test & Lint Python versions

Author: Andreas Schawo, DF1ASC (HamQTH, eQSL)

Convert ADIF ADI content (ham radio QSO logs) to dictionary and vice versa

The required/resulting dictionary format for ADI is

{
    'HEADER': 
        {Header param: Value,
         'USERDEFS': [list of user definitions]},
    'RECORDS': [list of records]
}

For ADI the header or each record is/must be a dictionary in the format

{
    ADIF parameter name: Text value,
}

For ADI a user definition is a dictionary of

{
    'dtype': one char representing the type,
    'userdef': the field definition text
}

The library also supports ADX import/export as compatible as possible to the ADI part. Though it will differ in handling application and user definitions. It relys on the ADX schemas from adif.org. For the ADX import there is no validation by default to be able to read fast.

Installation

The package is available via PyPI

pip install pyadif-file

Usage

For reading and writing files you can use adi.load or adi.dump. There is a corresponding variant for handling string: adi.loads and adi.dumps.

Here is an example for reading an ADI file:

from adif_file import adi

adi_doc = adi.load('qsos.adi')
for rec in adi_doc['RECORDS']:
    if "CALL" in rec:
        print(f'QSO on {rec["QSO_DATE"]} at {rec["TIME_ON"]} with {rec["CALL"]}')

====
QSO on 20231008 at 1145 with DL4BDF
QSO on 20231008 at 1146 with DL5HJK
QSO on 20231009 at 1147 with M3KJH
QSO on 20231010 at 1148 with HB4FDS

Exporting ADI

If an empty header is provided, the fields are generated with suiting defaults. Missing header fields are inserted.

Empty record fields and empty records are not exported at all.

*_INTL fields are not exported (see ADIF specification). If non ASCII characters are used the API raises an Exception.

Source Code

The source code is available at GitHub

Copyright

PyADIF-File © 2023-2025 by Andreas Schawo is licensed under CC BY-SA 4.0

PyADIF-File uses

  • xmlschema Copyright (c), 2016-2022, SISSA (Scuola Internazionale Superiore di Studi Avanzati)
  • xmltodict Copyright (c), 2012 Martin Blech and individual contributors

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

pyadif_file-1.3.2.tar.gz (24.8 kB view details)

Uploaded Source

Built Distribution

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

pyadif_file-1.3.2-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file pyadif_file-1.3.2.tar.gz.

File metadata

  • Download URL: pyadif_file-1.3.2.tar.gz
  • Upload date:
  • Size: 24.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.2

File hashes

Hashes for pyadif_file-1.3.2.tar.gz
Algorithm Hash digest
SHA256 54a9499b7dc3366411925a970b6b06b42134f09a04701985732481e031257b91
MD5 b3058cbbc941cecc917b08369f69fe01
BLAKE2b-256 1d4b4bb8c7fb987e15839ae0e4a80955db2d7e43e7b655633f95da031024b122

See more details on using hashes here.

File details

Details for the file pyadif_file-1.3.2-py3-none-any.whl.

File metadata

  • Download URL: pyadif_file-1.3.2-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.2

File hashes

Hashes for pyadif_file-1.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 45b64c43e7053900a7aedff5572cbebf4e60297b279a557b5ac9dd1fef9d6407
MD5 b29bacdf3c4357844fd0ff4849ca892f
BLAKE2b-256 881ba82ed0e7ca1934eead5e81d5466dc73b7584137fe35c30766684a90e9642

See more details on using hashes here.

Supported by

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