views:

47

answers:

1

Hi Guys

I have (yet another) powershell query. I have an array in powershell which i need to use the remove() and split commands on.

Normally you set an array (or variable) and the above methods exist. On the below $csv2 array both methods are missing, i have checked using the get-member cmd.

How can i go about using remove to get rid of lines with nan. Also how do i split the columns into two different variables. at the moment each element of the array displays one line, for each line i need to convert it into two variables, one for each column.

timestamp Utilization
--------- -----------
1276505880 2.0763250000e+00
1276505890 1.7487730000e+00
1276505900 1.6906890000e+00
1276505910 1.7972880000e+00
1276505920 1.8141900000e+00
1276505930 nan
1276505940 nan
1276505950 0.0000000000e+00

$SystemStats = (Get-F5.iControl).SystemStatistics     
$report = "c:\snmp\data" + $gObj + ".csv"

### Allocate a new Query Object and add the inputs needed
$Query = New-Object -TypeName iControl.SystemStatisticsPerformanceStatisticQuery
$Query.object_name = $i
$Query.start_time = $startTime
$Query.end_time = 0
$Query.interval = $interval
$Query.maximum_rows = 0 

### Make method call passing in an array of size one with the specified query
$ReportData = $SystemStats.get_performance_graph_csv_statistics( (,$Query) )

### Allocate a new encoder and turn the byte array into a string
$ASCII = New-Object -TypeName System.Text.ASCIIEncoding
$csvdata = $ASCII.GetString($ReportData[0].statistic_data) 

$csv2 = convertFrom-CSV $csvdata

$csv2
+1  A: 
Richard
Thank you very much, got it working. I had read a tutorial on Arraylists and hadn't realised there was a difference
Andrew
@Andrew: indeed, `ArrayList` and `Array` are completely different types. `ArrayList` is more flexible but has more overhead, in applications this might be significant, but unlikely in scripts. However all inbuilt collection operations in PSH create arrays.
Richard