powershell - Power shell append with export-csv -
i know question has been answered many times apologize asking again. wrote first power shell script perform aggregation task. cant figure out how append existing csv file. right script aggregating column, want modify aggregate multiple columns need append output.
my input file looks this:
salesid qty amount 1 2 5 1 3 6 2 5 9 2 6 5
my current output is:
salesid sum 1 5 2 11
but want output this:
salesid sum amount 1 5 11 2 11 14
my script:
import-csv $infilepath | group-object $groupbycolumname| %{ new-object psobject -property @{ $groupbycolumname= $_.name sum = ($_.group | measure-object $sumcolumnname -sum).sum } }| export-csv $outfilepath -encoding "utf8" -notype
please me out here. thanks.
the information there access need it.
$data | group-object salesid | %{ new-object pscustomobject -property @{ salesid = $_.name quantity = ($_.group.qty | measure-object -sum).sum amount = ($_.group.amount | measure-object -sum).sum } } | select-object salesid,quantity,amount | export-csv $outfilepath -encoding "utf8" -notype
for every salesid
sums of quantities , amounts. below console output before
salesid quantity amount ------- -------- ------ 1 5 11 2 11 14
Comments
Post a Comment