Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POTA: change MY_SIG_INFO from K-nnnnn to US-nnnnn #9

Open
wf5w opened this issue Apr 14, 2024 · 1 comment
Open

POTA: change MY_SIG_INFO from K-nnnnn to US-nnnnn #9

wf5w opened this issue Apr 14, 2024 · 1 comment

Comments

@wf5w
Copy link

wf5w commented Apr 14, 2024

Not sure, if this can be done already.

I have many files, whose park numbers MY_SIG_INFO were in the old K-nnnnn format.
Now they all are US-nnnnn format.

I could easily change the data part by using sed or some other tool. But the length part needs to be +1 like:
<MY_SIG_INFO:6>K-1234 to <MY_SIG_INFO:7>US-1234

Can that be done now. I suppose I could assume all the records in the adif file would have the same <MY_SIG_INFO>.

So basically, can edit --set change only PART of field, and adjust the length properly?

Jerry WF5W

@flwyd
Copy link
Owner

flwyd commented Apr 27, 2024

There isn't currently a way to do this purely within adif-multitool, but I'd like to think about how it could be expressed. A programmer's first instinct might be to do something sed-like, perhaps adifmt edit -replace 'my_sig_info=/^K-(\d+)/US-\1/'. Introducing user-supplied regular expressions is something that should be done with care (I intentionally haven't supported them yet), so I'd like to consider other ways to express this.

The simple proposal above also wouldn't be great if someone had a lot of DX POTA contacts and wanted update the park references for many countries at once; some kind of lookup table might be more useful here. (Though I suppose you could use sed to generate a really long adifmt edit command line.) Before enacting this, I'd like to try to think of other fields that someone would want to do this kind of replacement on to make sure the way the feature is expressed is general-purpose. If we don't add a general-purpose feature, I suppose it could be a special flag for adifmt fix that just knows the full mapping and applies it to POTA_REF, MY_POTA_REF, SIG_INFO, and MY_SIG_INFO.

One hack that might work for you, combining adif-multitool and sed:

adifmt cat -output adx my_log.adi | \
  sed 's/<MY_SIG_INFO>K-/<MY_SIG_INFO>US-/' | \
  adifmt save my_log_updated.adi

The ADX format gets you out of the field-length problem, and the XML tag name structure (one tag per line) is probably easier to work with than -output tsv and matching the right column.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants