Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Script to convert an Amateur Radio Cabrillo format log file into to an ADIF(Amateur Data Interchange Format) logfile.

A Cabrillo file has space delimited fields. An ADIF file has tag delimited fields and field order is not important. A Cabrillo file is used for entry into Ham radio contests like the ARRL Field Day. ADIF files are used to import contact data into logging software like QRZ.com. This process was used to create(with QRZlogfmt.pl) a Cabrillo log of 200+ entries and then import this file into my log on QRZ.com. I prefer to log on paper and I will use this process to enter and import contact data as I fill a log sheet.

Posted here so it can be found by the search engines. Other utilities that I have found are for Windows only.

#! /usr/bin/perl # adif.pl - Convert a Cabrillo format Ham Radio # log file into an ADIF format # # James M. Lynes Jr. - KE4MIQ # Created: July 16, 2021 # Last Modified: 07/17/21 - Initial header info # 07/20/21 - Change input filename # 07/20/21 - Add the file output # 07/21/21 - Changed output file extension to .adi # to make QRZ.com file-import happy # Notes: Handles two types of exchanges: # 1. Contest exchange, 11 fields - Class, Section # QSO:,7225,PH,2021-01-30,1943,KE4MIQ,1H,WCF,K5LDA,1H,A +L # # 2. Usual exchange, 9 fields - RST, RST # QSO:,7225,PH,2021-01-30,1943,KE4MIQ,59,K5LDA,59 # # Commas inserted manually into the Cabrillo file log.t +xt # Search/Replace all spaces with commas # Search/Replace ,,, with , # Search/Replace ,, with , # # Cabrillo file created with another Perl script(QRZlog +fmt.pl) # Unfortunately fields are defined by position # order within the record # # ADIF(Amateur Data Interchange Format) format # is a field order independant, tagged format # use strict; use warnings; open(my $infile, "<", 'log.txt') or die "Can't open log.txt: $!"; open(my $outfile, ">", 'adif.adi') or die "Can't open adif.adi: $!"; my @fields; my $fields; my $numfields; while(defined(my $line = <$infile>)) { chomp($line); @fields = split /,/, $line; $numfields = scalar @fields; print "Number of Fields: $numfields\n"; if($numfields == 11) { # Type 1, C +ontest $fields[1] = sprintf "%6.3f", $fields[1]/1000.; #KHz -> MHz $fields[1] =~ s/^\s+//; # Remove le +ading spaces $fields[2] =~ s/PH/SSB/; # Change PH + -> SSB $fields[3] =~ s/-//g; # Remove - +twice my $l1 = length($fields[1]); # Field len +gths my $l67 = length("$fields[6] $fields[7]"); my $l8 = length($fields[8]); my $l910 = length("$fields[9] $fields[10]"); print $outfile "<freq:$l1>$fields[1] "; # +Freq print $outfile "<mode:3>$fields[2] "; # +Mode print $outfile "<qso_date:8>$fields[3] "; # +Date print $outfile "<time_on:4>$fields[4] "; # +Time print $outfile "<rst_sent:$l67>$fields[6] $fields[7] "; # +Sent exch print $outfile "<call:$l8>$fields[8] "; # +Call print $outfile "<rst_rcvd:$l910>$fields[9] $fields[10]"; # +Recv exch print $outfile " <eor>\n"; # +End of Record } elsif($numfields == 9) { # Type 2, U +sual $fields[1] = sprintf "%6.3f", $fields[1]/1000.; #KHz -> MHz $fields[1] =~ s/^\s+//; # Remove le +ading spaces $fields[2] =~ s/PH/SSB/; # Change PH + -> SSB $fields[3] =~ s/-//g; # Remove - +twice my $l1 = length($fields[1]); # Field len +gths my $l6 = length($fields[6]); my $l7 = length($fields[7]); my $l8 = length($fields[8]); print $outfile "<freq:$l1>$fields[1] "; # +Freq print $outfile "<mode:3>$fields[2] "; # +Mode print $outfile "<qso_date:8>$fields[3] "; # +Date print $outfile "<time_on:4>$fields[4] "; # +Time print $outfile "<rst_sent:$l6>$fields[6] "; # +Sent exch print $outfile "<call:$l7>$fields[7] "; # +Call print $outfile "<rst_rcvd:$l8>$fields[8]"; # +Recv exch print $outfile " <eor>\n"; # +End of Record } }

James

There's never enough time to do it right, but always enough time to do it over...


In reply to Linux/Perl Cabrillo to ADIF Conversion Script by jmlynesjr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2021-08-01 09:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?