Hacker News new | past | comments | ask | show | jobs | submit login

Can anyone suggest something similar for Windows?



PowerShell can handle CSV files natively.

Here are the equivalent commands from the article:

  Import-Csv example.csv | Select-Object year, price   | Export-Csv -NoTypeInformation example-cut.csv
  Import-Csv example.csv | Sort-Object   year          | Export-Csv -NoTypeInformation example-sorted.csv
  Import-Csv example.csv | Where-Object  year -eq 1999 | Export-Csv -NoTypeInformation example-filtered.csv
PowerShell can also deal with JSON and XML in much the same way.


This neatly really illustrates why objects matter.

As cool as miller is, jq is also decidedly cool, but for json. Both claim that they are "like" awk, sed, cut, paste etc, but for $Format, where $Format is csv/tsv and json, respectively.

They both deal with much the same tasks, and there is considerable overlap.

What your PowerShell examples do not say, is how - after Import-Csv - you are no longer constrained to tools written for csv's (or json or ...). At that point the records of the csv file have become objects in the PowerShell type system (which is an extension of the .NET type system).

Another point about the corresponding functionality in PowerShell is how you do not need to convert back to csv, json or whatever. Your Export-Csv commands in your examples are only needed if you want to finally save the results as csv. Otherwise you would just keep the objects in a variable or flowing through the pipeline/script.

So TFAs 2nd example could be written

    ipcsv flins.csv | group county -n
If the data had been in json, one would write

    cat flins.json | convertfrom-json | group county -n
Which also means that data can be export through any cmdlet that exports or converts a stream of objects: Export-Csv, ConvertTo-Csv, ConvertTo-Html, ConvertTo-Json, ConvertTo-Xml, ...


PowerShell has solved this problem incredibly well. It often feels more Unix in its philosophy, than some of the newer *nix tools, I've encountered.


Take a look at LogParser:

https://technet.microsoft.com/en-us/scriptcenter/dd919274.as...

http://www.microsoft.com/en-us/download/details.aspx?id=2465...

It handles around 20 different input formats and is pretty fast. Has a COM API and is extensible. we use it to capture event log data from our windows platform. Has an edge over PowerShell when it comes to speed for certain types of tasks.


q has a windows installer as well.

http://harelba.github.io/q/

Harel




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: