Author Posts

February 26, 2016 at 7:31 am

Hi PowerGEEKS,

I want te following thing to do

I have a list of customers and prices view example below

number Price
10071 30.00
10071 5.00
10071 4.00
10071 0.00
10071 4.00
10071 3.75
10071 15.89
10071 0.00
10297 0.00
10297 0.00
10297 0.00
10297 0.00

Table 2
number Totalpricel
10071 46,75
10297 0

I want to import a CSV file then select the number ( customer number) inc. price and make a total price of it in another CSV file. Is this possible? Or do I need to use another programming language?

import-csv -path C:\temp\gegevens1.csv | select-object custumernumber, price | export-csv -path.

I hope my question is clear

Kind regards,

Gijs Liefers (Dutch name)

February 26, 2016 at 8:21 am

# Export customer and price totals
$groups = Import-Csv "C:\temp\gegevens1.csv" | Group-Object -Property customernumber
$groups | ForEach-Object {$measure = $_.group | Measure-Object -Property price -Sum 
[pscustomobject]@{'customer number' = $_.name;
                'total price'=$measure.Sum}} | 
Export-Csv -Path "C:\temp\gegevens1_total.csv" -NoTypeInformation -Append