Wednesday, October 31. 2018Replace 0 with Ø in ham radio call signs using PerlSince ham radio call signs can contain both the letter O and the digit 0 at the same time, the zeros are often represented as a slashed zero in print. But because there's no ready-hand (Unicode) character for this, the letter Ø is used most often instead, since one cannot always use a monospace font which already represents the zero in slashed form. (This problem could also occur in other cases, such as printing hashes or codes.) There's a lot of ham radio logging software outside that supports a workflow for printing QSL cards or label stickers, and I'm not sure if any of these supports the replacement of zeros with Ø before print—only in call signs, and not in other data such as date, time or frequency. The software I use on Ubuntu, CQRLOG, exports QSOs into a CSV file that can be read in by gLabels to perform or prepare the actual print. I wanted a step in between that transforms that CSV file by substituting that Ø only in call signs. It took me some time, but here's my solution (showing a bogus CSV line): $ echo "30-Oct-2018,12:04,AB0/K100ABC/P,14.104,F0und AA2/YZ300ZY/0" \
> | perl -pe '1 while s|(.*[A-Z0-9][A-Z0-9/]+)+0([A-Z0-9/]*.*)|\1Ø\2|g'
30-Oct-2018,12:04,ABØ/K1ØØABC/P,14.104,F0und AA2/YZ3ØØZY/Ø
I stuffed this regex pattern into this alias: alias qsl0='src=$HOME/path/to/qsl.csv; \
cp -p $src $src.orig; \ perl -pe \ "1 while s|(.*[A-Z0-9][A-Z0-9/]+)+0([A-Z0-9/]*.*)|\1Ø\2|g" \ < $src.orig > $src' Update: Fixed the pattern to allow prefixes that start with a digit.
Posted by Stephan Paukner
in Ham Radio, Information Technology
at
07:29
| Comment (1)
| Trackbacks (0)
Defined tags for this entry: programming, software
(Page 1 of 1, totaling 1 entries)
|
AboutCalendar
ArchivesCategoriesShow tagged entriesandroid antenna anti-spam apache astronomy austria automobile bash bluetooth bug career cloud collecting comic cooking cw debian dreams education electronics event fail fashion finance flickr fun gentoo geography german gnu-linux gnucash google google earth graphics guitar hardware history image processing internet kernel kids language lhc lifestyle linkroll literature ltd machine learning making mallorca mathematics matlab microsoft migration movies munich music nautilus numismatics octave pdf perl philately philosophy phone photo gear photography physics podcast politics postfix private programming public transport rant religion review samsung science security shtf social web software statistics storage sustainability symbian tablet time lapse transceiver tv usenet venice video virtualization wordplay work www yahoo youtube
Syndicate This BlogFollow meBookmarks
Powered by |