Working with large CSV file as shown below... Need to loop and create file for each distince AppID i.e below would have three files for AppID 1,3 and 5. Any help to do this with powershell would be appreciated. Thank you.
Col1 | AppID
data11 | 1
data12 | 1
data13 | 1
data31 | 3
data32 | 3
data51 | 5
data52 | 5
Assuming you want to use the bar as a delimiter, then this should work:
import-csv .\foo.csv -Delimiter '|' | group-object appid | foreach-object {
$_.group | Export-Csv "appid_$($_.name).csv" -NoTypeInformation }
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With