Plaintext-to-ADIF file converter written in Perl

General Description

This program converts a plain text file resembling (to a limited extent) a hand-written station log to widely used ADIF (Amateur radio Data Interchange Format). Originally, I named it SmartLog, to emphasize my program's outstanding position among hundreds of other ham radio utilities. Then I realized there were some 30-60 other "smartlogs" hanging around (including a company named "SmartLog Software") and decided to use the name DumbLog instead.

Sometimes less is more...

On top of all that, my program works in Linux, because it was written in Perl. Rejoice, fellow friends of the Penguin, yet another useful program! ...ehm, hope so...

How to use it

The converter works as a filter. Input data are read using diamond operator (<>). This means it reads normally from standard input; but if you enter a valid file name in the command line, Perl will use that file as input instead of stdin.

So the use is quite easy. If your input file is called 2001-summer.log and you want to generate ok1fou-2001a.adif, you just have to type:

[[email protected]]$ dumblog 2001-summer.log > ok1fou-2001a.adif

Input File Format

Here's a sample input log file.

File Header

The file must start with

#TEXTLOG 1.0
where 1.0 identifies file format version. The version actually does not have any effect on processing in the current version, but it must match regular expression /\d+\.\d+/.

Station Info Variables and Repeated QSO Data

Station info consists of data which are usually constant over a series of QSOs. This is typically my own call, QTH, grid locator, etc. This could be also mode and band used, although these data refer to QSO rather than the radio station description.

SmartLog reads station info into static variables, i.e. it keeps their values until the next occurrence of the variable. In other words, they are "remembered" and can be changed when needed. The program reads them on the fly.

There are two kinds of station info variables: QSO variables are detected by SmartLog due to their distinct format and therefore don't need a label. These variables are shown in Table 1:
Table 1: QSO constants
VariableFormat or /regex/
band/\d+c?m/
dateYYYY-MM-DD
mode(mode)
Any other station info variables must appear one per line in format

name=value
Anything after equal sign till the end of line is value assigned to the variable. Name must be one of the ADIF elements, otherwise you won't obtain valid ADIF file. SmartLog does not verify validity of ADIF elements. Empty assignment (no value) deletes the variable, i.e. the respective ADIF element will not appear in the output from this line on.

Variable QSO Data

Variable QSO data change with every QSO: time, call and RST sent.

SmartLog accepts RST received, but it is not required for successful export of ADIF record.
Table 2: QSO variables
VariableFormat
time_onhhmm
rst_sent>RST
rst_rcvd<RST
callanything else not matching QSO constant or variable

Other data

Data not used for ADIF conversion are separated by # character or double-slash //. Although SmartLog ignores these "comments" (think of Unix shell comments or comments in C++), they actually have a distinct format. At least, the first string after the comment character should be operator's name followed by comma. Next after comma should be QTH of the other station. Anyway, this part of each line is intended only for personal notes.

Output of ADIF Records

SmartLog attempts to output ADIF record after each line of input. ADIF record is output, however, only if all substantial QSO data (band, mode, date, time, call, RST sent) exist in the respective variables.

After output of ADIF record SmartLog deletes variables call, time_on, RST sent and RST received to prevent output of non-existent QSOs if the following QSO data were corrupted or incomplete.

Source Code

Have a look yourself.

Credits

Many thanks to Stipe Predanic, 9A6KSP, who found a bug in the program. DumbLog would not strip off comment past "#" character. OTOH using double-slash as comment separator worked well.


Copyright © 2001, Jindra Vavruska (OK1FOU). All rights reserved.