I am trying to show csv totals on a datagridview
but it doesn't seem to like it.
please see below code
$button70_Click = {
$rows = Import-Csv -Path "C:\Users\Name\Desktop\Testsdarts\301leader.csv"
$rows | Group-Object Player |
Select-Object Name, @{ n='Wins'; e={ ($_.Group | Measure-Object Wins -Sum).Sum } }
$dataGridView1.DataSource=[System.Collections.ArrayList]$rows
}
please see below how my csv
is laid out
as you can see it works perfectly in Powershell ISE
but the datagridview
doesn't, is there any way to get the ISE output in the datagridview
?
CodePudding user response:
Looking at the code, the gridview takes its input data from the $rows
variable - so you need to ensure you actually store the output from the Group-Object
/Select-Object
pipeline in $rows
by using the =
assignment operator:
$rows = $rows | Group-Object Player | Select-Object Name, @{ n='Wins'; e={ ($_.Group | Measure-Object Wins -Sum).Sum } }
# ^ remember to assign the modified data back to the variable