Compare commits
2 commits
953b0904c0
...
b2ad8854df
Author | SHA1 | Date | |
---|---|---|---|
b2ad8854df | |||
cc46bc3825 |
3
LICENSE
3
LICENSE
|
@ -1 +1,2 @@
|
|||
"THE BEER-WARE LICENSE" (Revision 42): <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return Poul-Henning Kamp
|
||||
"THE BEER-WARE LICENSE" (Revision 42):
|
||||
Wolfgang Kroener wrote this. As long as you retain this notice you can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return.
|
||||
|
|
10
README.md
10
README.md
|
@ -1,3 +1,11 @@
|
|||
# adif-pota2sig
|
||||
|
||||
Convert POTA fields in adif files to SIG and SIG_INFO fields
|
||||
Convert POTA fields in adif files to SIG and SIG_INFO fields
|
||||
|
||||
Parse adif file, if a record has one or more POTA_REF entries (delimited by a
|
||||
comma), add SIG POTA and SIG_INFO with reference. Multiply record such, that
|
||||
every POTA_REF entry is a separate record with own SIG_INFO.
|
||||
Extended adif file will be printed to stdout.
|
||||
|
||||
Usage:
|
||||
adif-pota2sig.pl logfile.adi > extended-logfile.adi
|
||||
|
|
65
adif-pota2sig.pl
Executable file
65
adif-pota2sig.pl
Executable file
|
@ -0,0 +1,65 @@
|
|||
#!/usr/bin/env perl
|
||||
#
|
||||
# SPDX-License-Identifier: Beerware
|
||||
# Wolfgang DM5WK Kroener wrote this file. As long as you retain this notice you
|
||||
# can do whatever you want with this stuff. If we meet some day, and you think
|
||||
# this stuff is worth it, you can buy me a beer in return.
|
||||
#
|
||||
# modified from perlmonks - TedPride - http://www.perlmonks.org/?node_id=559222
|
||||
# modified from https://scruss.com/blog/2011/05/23/parsing-adif-with-perl/
|
||||
#
|
||||
# Description:
|
||||
# Parse adif file, if a contact has one or more POTA_REF entries (delimited by
|
||||
# a comma), add SIG POTA and SIG_INFO with reference. Multiply contact such,
|
||||
# that every POTA_REF entry is a separate contact with own SIG_INFO.
|
||||
# Extendet adif file will be printed to stdout.
|
||||
#
|
||||
# Usage:
|
||||
# adif-pota2sig.pl logfile.adi > new-logfile.adi
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# use filename.adi as parameter
|
||||
open(my $FH, '<', $ARGV[0]) or die "$ARGV[0]: $!";
|
||||
|
||||
while (<$FH>) {
|
||||
print;
|
||||
# fast forward past header
|
||||
last if m/<EOH>\s+$/i;
|
||||
}
|
||||
|
||||
my @entry = ();
|
||||
my @pota_refs = ();
|
||||
while (<$FH>) {
|
||||
push @entry, $_;
|
||||
if (m/<EOR>\s+$/i) {
|
||||
# entry complete
|
||||
if (scalar(@pota_refs) > 0) {
|
||||
# add sig_info to each pota reference
|
||||
foreach my $ref (@pota_refs) {
|
||||
# print all except last
|
||||
print @entry[0 .. $#entry - 1];
|
||||
# insert POTA SIG
|
||||
print "<SIG:4>POTA\n";
|
||||
print "<SIG_INFO:" . length($ref) . ">" . $ref . "\n";
|
||||
# print last
|
||||
print $entry[-1];
|
||||
}
|
||||
} else {
|
||||
# no park reference in this entry
|
||||
print @entry;
|
||||
}
|
||||
# clear entry and pota refs for next entry
|
||||
@entry = ();
|
||||
@pota_refs = ();
|
||||
} elsif (m/^<POTA_REF:/) {
|
||||
# get last element of split >
|
||||
my $val = (split(/>/))[-1];
|
||||
chomp($val);
|
||||
# fill pota_refs with references
|
||||
@pota_refs = split(/,/, $val);
|
||||
chomp @pota_refs;
|
||||
}
|
||||
}
|
||||
close($FH);
|
Loading…
Reference in a new issue