4 ms·
If you have Windows, you have a tool that can do this already installed: PowerShell. (If you don't have Windows, PowerShell is free and open source [MIT license
by brushfoot 5y ago
If you have Windows, you have a tool that can do this already installed: PowerShell. (If you don't have Windows, PowerShell is free and open source [MIT license]. One of the first things I install on a new Linux or macOS box lately.)
The first example in PowerShell:
> Import-Csv example.csv | Sort-Object Color, Shape
To filter, use `Where-Object`:
> Import-Csv example.csv | Where-Object { $_.Color -eq 'purple' } | Sort-Object Color, Shape
Or using aliases:
> ipcsv example.csv | ? { $_.Color -eq 'purple' } | sort Color, Shape
JSON uses the same syntax -- just replace `Import-Csv` with `Get-Content` and `ConvertFrom-Json`:
> Get-Content example.json | ConvertFrom-Json | Select-Object Color -Unique
> purple
> red
> yellow
There's also `Group-Object` for aggregation.