Importing talkgroups and aliases

1,339 views
Skip to first unread message

ken...@gmail.com

unread,
Dec 5, 2020, 4:07:38 PM12/5/20
to sdrtrunk
I'm using SDRTrunk v0.5.0 Alpha 4 on Windows 10.  Is there any way to either import, or copy and paste, talkgroups from a .csv file?  I don't want to use Radio Reference unless that's the only way.  I have over 200 talkgroups and aliases in a .csv file that I would prefer not to have to enter manually. 

Ben Saladino

unread,
Dec 6, 2020, 8:41:02 AM12/6/20
to sdrtrunk
I wrote a little program for personal use that converts a .csv file into the xml format that can be pasted into your default.xml playlist.
It's very basic with NO error checking, but it helped me get thousands of radio and talk group aliases into SDRTrunk.
You definitely should backup your default.xml before pasting in anything.  

The .csv files should be formatted like below...
for talk groups

TG,Alias,Group
1000,Addison Fire 1,Addison
1001,Addison Fire 2,Addison
1002,Addison Fire 3,Addison
1003,Addison Fire 5,Addison
1005,Addison Fire 6,Addison
1006,Addison Fire 7,Addison

For radio IDs
_id,_label
7211802,FWFD Dispatcher
7211803,Station 8
7211804,Truck 8
7211805,T8 O?
7211806,Station 8
7211807,T8 L
7211808,T8 R
7211809,Ops 2
7211810,FWFD Safety 1
7211811,Safety 1
7211812,Shift Comander 
7211813,FWFD unit
7211814,Support 2

If you're interested, I've shared the program at the link below.
You just run it, open the .csv file that you want to import, and then it formats the data into .xml which can be pasted into your default.xml playlist. You can choose which alias list the data goes into. In my case, I defaulted it to "everything".
You need to avoid using any .xml reserved stuff like "/" ",", etc. in your descriptions, because it's a pretty simple program and that will break your playlist file. What I did was use notepad to search and replace "/" with "-", same for "," within my alias and groups.


Again, this was intended for my personal use, not for the public, but some of you may find it useful.
Happy Scanning,
Ben

Ben Saladino

unread,
Dec 6, 2020, 9:36:56 AM12/6/20
to sdrtrunk
I should have pointed out the program I wrote is for Windows. 

cande....@gmail.com

unread,
Dec 6, 2020, 9:53:40 PM12/6/20
to sdrtrunk
I knocked up a Python script that sort of does this. It's still a work in progress, however it takes a UniTrunker XML file and extracts out the Talkgroup and Radio aliases into CSV files for Sentinel and also writes out the specially formatted XML for pasting into SDR Trunk playlist.xml but only the TalkGroup aliases so far. I'll share to the group when it's eventually completed.
Be aware that if you paste an alias list into the Playlist.xml, any preexisting settings such as 'Record' will be lost. 

Imago Trigger

unread,
Dec 7, 2020, 10:15:09 AM12/7/20
to cande....@gmail.com, sdrtrunk
I made a perl script that scrapes radioreference site and makes a custom playlist.  Obviously you need to tweak it for your site and good luck no idea if it still even works but may be helpful

--
You received this message because you are subscribed to the Google Groups "sdrtrunk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sdrtrunk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sdrtrunk/ada90a16-ef3f-4f7b-83cb-b5404479e675n%40googlegroups.com.

Jeff Chapman

unread,
Apr 18, 2021, 1:52:21 PM4/18/21
to sdrtrunk
Thank you, After a few tweaks, I managed to bulk import my entire county.  Jeff


To unsubscribe from this group and stop receiving emails from it, send an email to sdrtrunk+u...@googlegroups.com.

Francesco Brocero

unread,
Jun 11, 2022, 9:36:18 AM6/11/22
to sdrtrunk
Hi Jeffrey,
could you please post your tweaks?
Thanks in advance

Jeff Chapman

unread,
Jun 18, 2022, 7:42:58 PM6/18/22
to Francesco Brocero, sdrtrunk
Francesco,

I had to do some digging to even remember this.  The code below is what I have.
It may or may not have my tweaks.

I would suggest that this MAY not work at all now that RR has updated to Verson 2.

Jeff

Jeff Chapman, WA3RIZ
 My Web Gallery - http://jeffchapman.net

#!\Strawberry\perl\bin\perl.exe
# imagot...@gmail.com - create a SDRTrunk playlist V3 xml from all talkgroups on radioreference.com
# see: https://www.radioreference.com/apps/db/
#  the only variable you need is "sid" or System ID from the RR database.
#   adjust the tail of your XML as necesssary...
#   provide your own ignore.txt list if you wish othewise everything is set to record on the same priority!

my $sid = 1234; #change me!
my $list = "MontcoP25"; #change this to whatever your system name is, if you want

use common::sense;
use LWP::UserAgent;

open(IGNORE,"ignore.txt");
my @lines = <IGNORE>;
my @ignore;
foreach (@lines) {
my ($id,$tag) = split(/\t/,$_);
push(@ignore,$id);
}
close IGNORE;

my $url = "https://www.radioreference.com/apps/db/?sid=$sid&opt=all_tg";
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => $url);
my $resp = $ua->request($req);
my $xml;

if ($resp->is_success) {
my $message = $resp->decoded_content;
$message =~ s/\n//gi;
my $data;
if ($message =~ /<b> Talkgroups<\/b>(.*)/) {
$data = $1;
}
my @rows = split("<tr>",$data);
my $pos = 0;
foreach my $row (@rows) {
$pos++;
next if $pos < 3;
my @cols = split("</td>",$row);
my $dec;
if ($cols[0] =~ /<td class="td\d t" nowrap>(.*)/) { $dec = $1; $dec =~ s/\s//gi; }
my $alpha;
if ($cols[3] =~ /<td nowrap class="td\d t">(.*)/) { $alpha = $1; }
my $desc;
if ($cols[4] =~ /<td width="100%" class="td\d t">(.*)/) { $desc = $1; $desc =~ s/&nbsp;/ /gi; $desc =~ s/\s$//gi;}
my $group;
if ($cols[6] =~ /<td nowrap class="td\d t">(.*)/) { $group = $1; $group =~ s/&nbsp;/ /gi; $group =~ s/\s$//gi;}


$desc =~ s/^\s+|\s+$//g;
$group =~ s/^\s+|\s+$//g;
$desc =~ s/\"/\'/gi;
$desc =~ s/![:alnum:]//gi;
$desc =~ s/\&/\&amp;/gi;

if (length($dec) == 1) {
$dec = "000$dec";
}
if (length($dec) == 2) {
$dec = "00$dec";
}
if (length($dec) == 3) {
$dec = "0$dec";
}
next if !$dec;
my $record = qq{
<id type="record"/>};
my $pri = 69;
if (grep $_ eq $dec, @ignore) {
 $record = "";
 $pri = "-1";
}
$xml .= qq{
<alias name="$alpha $desc" group="$group" color="-16777216"  list="$list" iconName="No Icon">
<id type="priority" priority="$pri"/>
<id type="talkgroup" value="$dec" protocol="APCO25"/>$record
</alias>};
}
print "Processed about $pos aliases\n";
}

open(PLAYLIST,">default.xml");

#the head
print PLAYLIST qq{<playlist version="3">};

#the aliases
print PLAYLIST $xml;

#the tail
print PLAYLIST qq{
  <channel name="ARMER_ANOKA" system="1" site="2" enabled="true" order="1">
    <record_configuration/>
    <source_configuration type="sourceConfigTunerMultipleFrequency" source_type="TUNER_MULTIPLE_FREQUENCIES">
      <frequency>853387500</frequency>
      <frequency>852887500</frequency>
      <frequency>851937500</frequency>
      <frequency>852387500</frequency>
    </source_configuration>
    <event_log_configuration/>
    <decode_configuration type="decodeConfigP25Phase1" traffic_channel_pool_size="30" ignore_data_calls="false" modulation="CQPSK"/>
    <aux_decode_configuration/>
    <alias_list_name>armer</alias_list_name>
  </channel>
  <channel name="ARMER_RAMSEY" system="1" site="2" enabled="true" order="2">
    <record_configuration/>
    <source_configuration type="sourceConfigTunerMultipleFrequency" source_type="TUNER_MULTIPLE_FREQUENCIES">
      <frequency>852087500</frequency>
      <frequency>853762500</frequency>
      <frequency>853712500</frequency>
      <frequency>853362500</frequency>
    </source_configuration>
    <event_log_configuration/>
    <decode_configuration type="decodeConfigP25Phase1" traffic_channel_pool_size="30" ignore_data_calls="false" modulation="CQPSK"/>
    <aux_decode_configuration/>
    <alias_list_name>armer</alias_list_name>
  </channel>
</playlist>
};
close PLAYLIST;
exit;



You received this message because you are subscribed to a topic in the Google Groups "sdrtrunk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sdrtrunk/yIoUXAdF-dg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sdrtrunk+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sdrtrunk/ee4a0ebe-7011-4766-9f13-e4d4ed0e2ad3n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages