Starting with a 500,000 line CSV, I need to split the files by day and hour (the second and third columns). I've tried the modify the group to include the hour and while I see the hour get added to my filename, I get no results in the exported file.
The foreach doing the work:
foreach ($group in $data | Group Day,hour) {
$data | Where-Object { $_.Day -and $_.Hour -eq $group.Name }
ConvertTo-Csv -NoTypeInformation |
foreach {$_.Replace('"','')} |
Out-File "$Path\Testfile_$($group.name -replace $regexA, '').csv"
Sample Data:
Bob,1/27/2012,8:00,Basic,Operations Charlie,2/3/2012,9:00,Advanced,Production Bill,3/7/2012,10:00,Advanced,Production
$data | Where-Object { $_.Day -and $_.Hour -eq $group.Name }->$_.Groupcontains all the things in the group, no need to rescan all 500,000 things to try and make up the group again.$_.Day -and $_.Houris not doing what you think, this is a boolean operator and returns$Truewhich will never match the group name.