Last active
August 1, 2018 16:26
-
-
Save anthonydiiorio/fc0a812b924c6d7fd8a40b1026913c81 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$database = "https://ham-digital.org/status/users.csv" | |
$csv = "datadump.csv" | |
Write-Host "Downloading database CSV" | |
Invoke-WebRequest $database -OutFile $csv | |
If (Test-Path $csv){ | |
$reader = [System.IO.File]::OpenText($csv) | |
$writer = New-Object System.IO.StreamWriter 'DSDPlus.radios' | |
Write-Host "Converting database dump to DSDPlus.radios" | |
for(;;) { | |
$line = $reader.ReadLine() | |
if ($null -eq $line) { | |
break | |
} | |
$data = $line.Split(",") | |
$protocol = "DMR" | |
$id = $data[0] | |
$networkID = 0 | |
$group = 712 | |
$priority = 50 | |
$override = "Normal" | |
$hits = 0 | |
$timestamp = $(get-date).ToString("yyyy/MM/dd HH:mm"); | |
$data[2] = $data[2].Trim(); | |
$remark = '"' + $data[1] + ': ' + $data[2] + ' in ' | |
if ($data[3].length) | |
{$remark = $remark + $data[3] + ', '} | |
if ($data[4].length) | |
{$remark = $remark + $data[4] + ', '} | |
$remark = $remark + $data[5] + '"' | |
$writer.WriteLine('{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}', $protocol, $networkID, $group, $id, $priority, $override, $hits, $timestamp, $remark) | |
} | |
$reader.Close() | |
$writer.Close() | |
Write-Host "Cleaning up..." | |
If (Test-Path $csv){ | |
Remove-Item $csv | |
} | |
} | |
Else{ | |
Write-Host "Error: Could not download database dump from DMR-Marc." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment