Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Export csv sort by column

$
0
0

$tag_file = Select-String -pattern "!"  $fname_tag
For ($a=0; $a -le $tag_file.length; $a++)
{
    $a_tag = $tag_file[$a] -split "!"
    if($a_tag[1] -eq "1")
    {
        $type= "P"
    }
    if($a_tag[1] -eq "2")
    {
        $type= "A"
    }
    if($a_tag[1] -eq "3")
    {
        $type= "C"
    }
    if($a_tag[1] -eq "4")
    {
        $type= "S"
    }

 $employee = New-Object System.Object
 $employee | Add-Member -MemberType NoteProperty -Name "Time" -Value $($a_tag[8])
 $employee | Add-Member -MemberType NoteProperty -Name "Type" -Value $($type)
    $employee | Add-Member -MemberType NoteProperty -Name "Station" -Value $($a_tag[3])
 $employee | Add-Member -MemberType NoteProperty -Name "Point" -Value $($a_tag[4])
    $employee | Add-Member -MemberType NoteProperty -Name "Type" -Value $($a_tag[6])
 $employee | Add-Member -MemberType NoteProperty -Name "Comment" -Value $($a_tag[11])
    $employee | Add-Member -MemberType NoteProperty -Name "creator" -Value $($a_tag[12])
 $employees += $employee
 Start-Sleep -Seconds 1
    $employees  | Export-Csv  -Path "c:\temp\test\tag_rpt01.csv" -NoTypeInformatio


}

    "EMS Tag Report,Date: $(Get-Date)" | out-File -FilePath "c:\temp\test\tag_rpt01.csv" -Encoding utf8
    $csv | Out-File -FilePath "c:\temp\test\tag_rpt01.csv" -Encoding utf8 -Append

 

how can sort by order column?

the field shall by sorted by the following sequence in ascending order:

station-> Point  -> tyep ->comment ->creator


Viewing all articles
Browse latest Browse all 6937

Latest Images

Trending Articles



Latest Images