Created
April 23, 2015 04:34
-
-
Save dstreefkerk/cf23a7d8a818f28cb36f to your computer and use it in GitHub Desktop.
Retrieves data from https://data.cityofchicago.org and shows the last 1 month's crime data
This file contains 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
# Get the data, convert it to JSON | |
$jsonData = Invoke-WebRequest "https://data.cityofchicago.org/resource/ijzp-q8t2.json" | ConvertFrom-Json | |
# Filter our data set down to only the last month's crimes. Note that the data feed has a built-in lag of 7 days | |
$lastMonthsData = $jsonData | Where-Object {($_.date | get-date) -gt ((get-date).AddMonths(-1))} | |
# Show results, allowing user to select categories first and then view individual crimes | |
$lastMonthsData | Group-Object -Property primary_type | Sort-Object Count -Descending | Select-Object Name,Count,Group | Out-GridView -Title "Select a category (or multiple) to view details" -OutputMode Multiple | Select-Object -ExpandProperty Group | select primary_type,description,location_description,date,latitude,longitude,block,domestic,arrest,case_number | Sort-Object date -Descending | Out-GridView -Title "Crime Details" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment