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

Another CSV sorting question.

$
0
0

Hi,

I am new to powershell but need to sort some data from a csv file but what ever I try, the result is an error. I will try to paste a small part of the csv file:

date,prio,stat,cp,comp,tag,state,val,analog,value

"2014-07-07 00:00:14","1","ALM","IKCP15","HI_QMI_BL","11QA0003_52","CHANGE","1","0.000000","-2.554552",""

"2014-07-07 00:00:18","1","ALM","IKCP11","HI_QMI_BL","11QA0003_52","CHANGE","1","0.000000","-2.554552",""

"2014-07-07 00:01:17","1","ALM","IKCP80","F_VU40","40GB0004","CHANGE","1","0.000000","60.100002",""

"2014-07-07 00:01:17","1","ALM","IKCP77","F_VU40","40KBS0008","CHANGE","1","0.000000","60.100002",""

"2014-07-07 00:01:59","1","ALM","IKCP06","HI_QMI_BL","11QA0003_52","CHANGE","1","0.000000","-2.554552",""

"2014-07-07 00:02:03","1","ALM","IKCP04","HI_QMI_BL","11QA0003_52","CHANGE","1","0.000000","-2.554552",""

The command I use to read is: $a = import-csv .\test.txt | format-table

Now I need to sort the data on the 4th column, cp. So I use sort-object cp But no mather where I put this, at the end when reading the file, just $a = $a | sort-object or from $a to $b the output is :

out-lineoutput : The object of type "Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData" is not valid or not

 in the correct sequence. This is likely caused by a user-specified "format-*" command which is conflicting with the de

fault formatting.

    + CategoryInfo          : InvalidData: (:) [out-lineoutput], InvalidOperationException

    + FullyQualifiedErrorId : ConsoleLineOutputOutOfSequencePacket,Microsoft.PowerShell.Commands.OutLineOutputCommand 

What am I missing? Thanks in advance 

Robbert.


Viewing all articles
Browse latest Browse all 6937

Latest Images

Trending Articles



Latest Images