Working with numeric operators from a csv file.
i searched around answer this, couldn't find looking for. my google-foo (**cough** bing-foo, mean) hasn't steered me in right direction time around. i want i've done before, need guidance. imported large csv file thousands of entries in it. want filter file , create 2 new ones based on numeric values in file.
here's simplified example of script looks like. data gets imported $file, i'm piping clause numeric comparison on field using standard operators. that's basic logic....what need make work?
thanks.
$file = import-csv file.csv $export_file1 = "export_file1.csv" $export_file2 = "export_file2.csv" $export_data1 = $file|?{$_.numeric_field -ge 100} $export_data2 = $file|?{$_.numeric_field -lt 100} add-content $export-file1 $export_data1 add-content $export-file2 $export_data2
hi,
here's can play with:
$data = import-csv .\input.csv $data | { [int]$_.numeric_field -ge 100 } | export-csv .\100andover.csv -notypeinformation $data | { [int]$_.numeric_field -lt 100 } | export-csv .\lessthan100.csv -notypeinformation
Windows Server > Windows PowerShell
Comments
Post a Comment