header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

We have a new sponsor!  Introducting Pragma Systems.  See the home page for details.

a ps script that reads columns of a tsv file and search for values
Last Post 01 Mar 2010 10:01 PM by Cruisader03. 1 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
zerozero7User is Offline
New Member
New Member
Posts:12
Avatar

--
01 Mar 2010 02:37 PM  
Hi,

I am having problem of searching for some specific values from a columns in a tsv file:

This is a example of the tsv file.
"(PDH-TSV 4.0) (Eastern Standard Time)(300)"    "\\xxxxx\Memory\% Committed Bytes In Use"    "\\xxxxx\Memory\Available MBytes"    "\\xxxxx\Memory\Free System Page Table Entries"    "\\xxxxx\Memory\Pool Paged Bytes"
"02/26/2010 17:03:01.094"    "4.9980826913423728"    "2495"    "191430"    "72187904"
"02/26/2010 17:13:01.113"    "4.3538558027374465"    "2529"    "191766"    "69058560"
"02/26/2010 17:23:01.152"    "4.3622405344763404"    "2529"    "191782"    "69058560"

As you can see, there are five columns and are separated by "tab".
The first column has no interest, as it only display the time.
I need a script that can read those columns and search for specific number.
Let say, in column 2 i want to search for number that is greater than 4.7. If matches, I need it to write the column's header, the time, and the exact values into a txt file.
and, similar for the other columns.

This is what I got as starting point,
PS C:\> Import-tsv c:\logs\MB.tsv -header ("\\xxxxx\Memory\% Committed Bytes In Use", "\\xxxxx\Memory\Available MBytes")...... |foreach {
search for number and display to |out-file -append c:\logs\MB_found.txt
}

Thanks
Cruisader03User is Offline
Basic Member
Basic Member
Posts:243
Avatar

--
01 Mar 2010 10:01 PM  
$data = @()
$list = gc file.tsv


foreach ($line in $list) {
$line = $line.Replace("`"","")
$row = "" | Select One,Two,Three,Four,Five
$row.One = ($line.Split("`t"))[0]
$row.Two = ($line.Split("`t"))[1]
$row.Three = ($line.Split("`t"))[2]
$row.Four = ($line.Split("`t"))[3]
$row.Five = ($line.Split("`t"))[4]
$data += $row
}
foreach ($line in $data) {
if ($line.Two -ge 4.7) {
OUTPUT TO FILE AS DESIRED HERE
}

Try that on for size.
When at first you don't succeed Step-Into

http://theposherlife.blogspot.com
http://www.jandctravels.com

You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 footer
footer