PyADIF-File
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
Copyright
PyADIF-File © 2023 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
Metadata
Release files for PyADIF-File 1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyadif_file-1.5.tar.gz | 27.2 kB | Without provenance | Details for pyadif_file-1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyadif_file-1.5-py3-none-any.whl | Python 3 | none | any | Details for pyadif_file-1.5-py3-none-any.whl |
Total release size: 51.4 kB
Release files / pyadif_file-1.5.tar.gz
| Download URL | pyadif_file-1.5.tar.gz |
|---|---|
| Size | 27.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
68e43ce73dfef2b738a5e53f17f49e05b93de357a21d7160109c59f0c90eb57a
|
|
BLAKE2b-256 checksum How to use checksums |
1420149059a09e0c7ead651eb08555643dfaf193a04324f16339647eb43dce6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / pyadif_file-1.5-py3-none-any.whl
| Download URL | pyadif_file-1.5-py3-none-any.whl |
|---|---|
| Size | 24.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4ee212fb0b936b47c491e0aaefe3feb75f718fde5a94c280eccf432104b4cb5f
|
|
BLAKE2b-256 checksum How to use checksums |
cbd30c1adba1540d58e19287c3c7bae3252ae1ee484ffe96ede6623d9317c516
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for PyADIF-File 1.5
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.