Convert ADIF ADI (hamradio QSO log) content to dictionary and vice versa
  • Python 96.4%
  • Makefile 3%
  • Batchfile 0.3%
  • Shell 0.3%
Find a file
Andreas Schawo d68ccf7a33
All checks were successful
Test & Lint / build (3.10) (push) Successful in 53s
Test & Lint / build (3.12) (push) Successful in 56s
Test & Lint / build (3.14) (push) Successful in 59s
Removed UndefinedElementException and fixed test cases
2026-03-06 17:02:01 +01:00
.forgejo/workflows WorkflowMigration (#4) 2025-12-26 09:42:26 +01:00
examples Added replace non ASCII 2026-03-06 08:03:02 +01:00
src/adif_file Removed UndefinedElementException and fixed test cases 2026-03-06 17:02:01 +01:00
test Removed UndefinedElementException and fixed test cases 2026-03-06 17:02:01 +01:00
.gitattributes Fixed handling of encodings to prevent exceptions (issue #2) 2024-07-22 20:28:29 +02:00
.gitignore Load and dump from/to file 2023-11-10 18:17:39 +01:00
LICENSE Fixed license, copyright and pyproject.toml 2024-08-29 07:39:18 +02:00
make.bat Switched to Makefile 2024-09-24 19:41:53 +02:00
Makefile Fixed Makefile 2026-03-06 08:02:38 +01:00
pyproject.toml Changed project URLs for Codeberg and tested against Py 3.14 2025-12-29 19:15:17 +01:00
README.md Added replace non ASCII 2026-03-06 08:03:02 +01:00
release.bat Build for PyPI 2023-10-20 21:44:17 +02:00
release.sh Added Linux build scripts and removed __version__.py from repo 2023-10-22 17:39:12 +02:00
requirements.txt Removed UndefinedElementException and fixed test cases 2026-03-06 17:02:01 +01:00

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': 
        {'ADIF_HEADER_FIELD_NAME': '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_FIELD_NAME': 'Value',
}

The value can be a str, int, float or bool. Booleans are translated to Y or N.

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.

For more details visit the API documentation

Examples

See example.py for a complete example. Running example.py should produce example.adi and example.adx.

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). Non ASCII characters are substituted on export by default with an underscore _. A warning will be raised. Deactivating this will rais an exception for each field containing non ASCII chars.

To substitute non ASCII chars you may want to provide a different substitution char e.g. # or a substitution map e.g. for german lang {'ä': 'ae', 'ß': 'ss'}.

Source Code

The source code is available at Codeberg

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