Is there a way to sum (i.e., total) the values of a specific property by “sub-groups” of objects in a CSV file? An example is best. The CSV file looks like the ff:
12 , 50
12 , 10
I’d like to create a file that looks like:
I did it by looping through each object with Foreach … using the $_ cursor and additional variables to keep track of the changes.
I also thought Measure-object’s -SUM could do the job, but it seems it can only sum the CSV file’s Amount property. I’m looking for a “Powershell way” to use existing cmdlets and pipeline processing.
Would be grateful for any hints, suggestions, tips.