Giter Site home page Giter Site logo

pselect's Issues

Example FromPipeline - error on PowerShell 6 (Core)

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

Problem transforming Group-Object to PSelect

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:

  1. the Group-Object code takes about 10 seconds to run. PSelect takes 4:17min to run. That's about 25 times longer.
  2. Is it possible to sort the output on the Count column and not the Length column?
  3. The Length column is obviously sorted alphabetically and not numerically. This looks like a bug.
  4. Is it possible to add the "raw data" (the Group column from Group-Object)?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.