cdhunt / pselect Goto Github PK
View Code? Open in Web Editor NEWPowerShell DSL for aggregating data
License: MIT License
PowerShell DSL for aggregating data
License: MIT License
Can you give some information regarding the difference and similarity between PSelect and PowerShell's Group-Object
?
Field : Cannot validate argument on parameter 'Unit'. The argument "Field" does not belong to the set "Currency;Percentage;Seconds;Minutes;Hours;Days;Weeks;Months;Years" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again.
At line:1 char:51
+ Get-Process | PSelect { Field ProcessName Field WorkingSet -a ...
+ ~~~~~
+ CategoryInfo : InvalidData: (:) [Field], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Field
GroupBy is required.
At F:\cygwin\home\thorsten\.config\powershell\Modules\PSelect\0.2.2\PSelect.psm1:45 char:13
+ Throw "GroupBy is required."
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (GroupBy is required.:String) [], RuntimeException
+ FullyQualifiedErrorId : GroupBy is required.
The same code works fine on Windows PowerShell 5.1
I've got some example code. The code reads a file with about 300,000 words - one per line - and groups the words by length. The grouped output is sorted by count:
$file = 'F:\cygwin\home\thorsten\python\Wordlist.txt'
$content = Get-Content -Path $file -ReadCount 0
$content | Group-Object -Property Length | Sort-Object -Property Count
This is the output:
Count Name Group
----- ---- -----
5 24 {formaldehydesulphoxylate, pathologicopsychological, scientificophilosophical, tetraiodophenolphthalein...}
17 23 {anthropomorphologically, blepharosphincterectomy, epididymodeferentectomy, formaldehydesulphoxylic...}
31 1 {*, 0, 1, 2...}
[...]
43555 8 {!@#$%^&*, 0racl38i, 0racl39i, 0racle10...}
46919 10 {abalienate, abaptiston, abasedness, abbagliamo...}
48228 9 {0racle10i, 123456789, 199220706, <invalid>...}
The PSelect code I came up with looks like this
$content | PSelect {
Field -Name Length -As Count -Count
Field -Name Length
GroupBy -Name Length
SortData
}
The output looks like this:
Count Length
----- ------
31 1
46919 10
26902 11
[...]
34384 7
43555 8
48228 9
Now my questions and observations:
Group-Object
code takes about 10 seconds to run. PSelect
takes 4:17min to run. That's about 25 times longer.Count
column and not the Length
column?Length
column is obviously sorted alphabetically and not numerically. This looks like a bug.Group
column from Group-Object
)?A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.