Script to create a specific WSPR call csv file
Posted by admin | Posted in Misc Scripts | Posted on 02-01-2012-05-2008
0
I had the need to download a number of WSPR CSV files so I threw together a PowerShell script. In case anyone has the same need here is the PowerShell code to use as is at your own risk. It goes out to the WSPR web site and downloads the month you specify unzips the file and then creates a CSV file of only spots with the call specified, then it deletes the downloaded ZIP and CSV files leaving only a file by the name of the call specified .csv. This was coded for a quick project and DOES NOT have any type of error checking and it assumes you know what input parameters are needed. I called the script download.ps1 and it needs three parameters: the year, month and call.
# Script to download WSPR spot file, unzip it and create a file with spots for only the specified call.
# By N9RO January 01, 2012
# To run program CD to the script’s directory and type ./download.ps1 year month call in the
# PowerShell window. New file will appear the the script’s directory.
param($year,$month,$call)
$source = “http://wsprnet.org/archive/wsprspots-$year-$month.csv.zip”
echo “***** Downloading file from: $source *****”
Get-Date -DisplayHint time
$destination = “c:\projects\wspr-adif\wsprspots-$year-$month.csv.zip”
$wc = New-Object System.Net.WebClient
$wc.DownloadFile($source, $destination)
echo “***** File Download Complete *****”
# Now unzip File
echo “***** Unzipping WSPR File *****”
Get-Date -DisplayHint time
$shell_app=new-object -com shell.application
$filename = “wsprspots-$year-$month.csv.zip”
$zip_file = $shell_app.namespace((Get-Location).Path + “\$filename”)
$destination = $shell_app.namespace((Get-Location).Path)
$destination.Copyhere($zip_file.items())
echo “***** Unzip complete *****”
# Create Call file
echo “***** Creating WSPR Call File for $call *****”
Get-Date -DisplayHint time
$csvfile = “C:\projects\wspr-adif\wsprspots-$year-$month.csv”
Select-String -Simple $call $csvfile >> “$call.csv”
echo “***** Call file created for $call *****”
# Delete files not needed
echo “***** Deleting Files Not Needed *****”
Get-Date -DisplayHint time
Remove-Item “$csvfile”
Remove-Item “$filename”
echo “***** Files deleted *****”
Get-Date -displayhint date
Get-Date -DisplayHint time
echo “========== WSPRDB Program Complete ==========”
Here is what it looks like when I run the program:
PS C:\projects\wspr-adif> ./download.ps1 2011 11 n9ro
***** Downloading file from: http://wsprnet.org/archive/wsprspots-2011-11.csv.zip *****
10:54:23 PM
***** File Download Complete *****
***** Unzipping WSPR File *****
10:55:13 PM
***** Unzip complete *****
***** Creating WSPR Call File for n9ro *****
10:55:16 PM
***** Call file created for n9ro *****
***** Deleting Files Not Needed *****
10:55:24 PM
***** Files deleted *****
Saturday, December 31, 2011
10:55:24 PM
========== WSPRDB Program Complete ==========
PS C:\projects\wspr-adif>
