excel - Mathmatically adding arrays in PowerShell -
i have 2 arrays need add (along later subtract , multiply). first labeled $agrp , contains data being pulled range in excel sheet. have $bgrp pulling range same excel sheet. add them mathematically. far, can them combine new array (now double size). suggestions?
if want treat arrays independently, can use this:
$egrp = new-object system.collections.arraylist ($i=0; $i -lt $agrp.count; $i++){ $egrp += $agrp[$i] + $bgrp[$i] }
although don't because it's not "powershell". here's suggest if need extracted directly csv:
$egrp = new-object system.collections.arraylist import-csv $csv_path | %{[int]$_.agrp + [int]$_.bgrp} | %{$egrp += $_}
note $_.agrp
, $_.bgrp
represent names of columns of csv (in first line). $csv_path
string path or file object of csv.
wiki
Comments
Post a Comment