Is it possible to import Aliases?

243 views
Skip to first unread message

Mike Jones

unread,
Dec 28, 2017, 10:45:14 AM12/28/17
to sdrtrunk
My state system has 2926 talk groups!
Is there any way to import alias data in bulk?

Hans H

unread,
Dec 28, 2017, 4:05:24 PM12/28/17
to sdrtrunk
#!/usr/bin/perl
#
# Convert RadioReference.com talkgroup csv download into xml to insert into sdrtrunk playlist.xml
#
# Usage: perl make_playlist.pl <csv filename> > <aliasfile.xml>
#
# Jon Anhold (j...@anhold.com) N8USK - 2016-08-19

use Data::Dumper;
my ($FILE) = @ARGV;
open FILE
, "<$FILE";
while (<FILE>) {
   
my @line = ();
   
next if $_ =~ /^Decimal/; #skip header
    chomp
;
   
my ($decimaltg,$subfleet,$alphatag,$mode,$desc,$tag,$category) = split(',');
   
my $hextg = sprintf("%X", $decimaltg);
   
my $priority = "50";
   
if ($mode eq "E") { $priority = "-1" } # set encrypted channels to "Do Not Monitor"

   
# edit this to set certain categories to "Do Not Monitor"
#    if ($tag =~ /Sanitation|Public Works/) { $priority = "-1" }

   
print "<alias color=\"-16777216\" group=\"$category\" iconName=\"No Icon\" list=\"WisCom\" name=\"$alphatag: $desc\">\n";
   
print "<id xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"talkgroupID\" talkgroup=\"$hextg\"/>\n";
   
print " <id xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"priority\" priority=\"$priority\"/>\n";
   
print "</alias>\n";
 
}

The above script can be used; you might have to modify it slightly for your needs.  The alias are stored in the playlist file which contains other system data as well.

Mike Jones

unread,
Dec 28, 2017, 11:41:02 PM12/28/17
to sdrtrunk
Great, I'll give that a try!
Thanks very much.

Hans H

unread,
Dec 29, 2017, 8:41:39 AM12/29/17
to sdrtrunk
Just a hint, you need to be careful not to import certain special characters without first escaping them such as the & sign and certain groups of quotes. Check your startup log for hints if nothing loads. Also remember that sdrtrunk replaces the playlist file with a new one if something is wrong so be sure to backup your work.

ve1jot

unread,
Dec 29, 2017, 9:30:45 AM12/29/17
to sdrtrunk
on our P25 system, in the RR database, the leading zero is not there, for instance, 0bd8 ends up as just "bd8", so I wonder, do I need to add a leading zero for it to work in sdrtrunk?

ve1jot

unread,
Dec 29, 2017, 11:28:52 AM12/29/17
to sdrtrunk
Answer to my own question...I've discovered yes, the leading zeroes have to be there...

Dave C

unread,
Feb 26, 2018, 7:51:10 AM2/26/18
to sdrtrunk
Is there a more detailed set of directions for someone who is not that familiar with scripts?   My downloaded file is called trs_tg_2354.csv . Do I need perl?  Not really sure what exactly to do with this..

Thanks

david...@gmail.com

unread,
Feb 27, 2018, 9:34:28 AM2/27/18
to sdrtrunk
I used strawberry perl on windows. I think i ended up running "perl playlist.pl > playlist.xml I then used notepad to insert the relevant XML into the right area of the real playlist.xml

Dave C

unread,
Feb 27, 2018, 3:46:53 PM2/27/18
to sdrtrunk
Completely lost here. Installed strawberry perl. Do I take the text above and make it a bat file? And then sub the name of my csv file? then type perl playlist.pl > playlist.xml into strawberry?

Managed to get it to create a xml file but its not have any talk groups.

Hans

unread,
Feb 28, 2018, 8:47:02 PM2/28/18
to sdrtrunk
You'll need to cut and paste the script into a text file, you can save it with any name but the common perl script ends with the .pl extension, and the name of this script used in the example is make_playlist.pl.

Once you have that file somewhere on your computer (or it might need to be in the strawberry perl directory, I don't use windows) then you execute the script with the perl command.  The format is: perl <name of perl script.pl> <name of CSV file with talkgroups.csv> > nameofoutputfile.xml

So for you you would type: "perl make_playlist.pl trs_tg_2354.csv > trs_playlist.xml"

I hope this helps.


On Thursday, December 28, 2017 at 9:45:14 AM UTC-6, Mike Jones wrote:
Reply all
Reply to author
Forward
0 new messages