Search value in a CSV file and do something with it!

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of random commandline random commandline 7 months, 1 week ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #35741
    Profile photo of
    Anonymous

    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)

    #35742
    Profile photo of random commandline
    random commandline
    Participant
    # 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
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.