How To Powershell Import CSV And Parse Data Out Of CSV Using Comparison Operators

preview_player
Показать описание
How To Powershell Import CSV And Parse Data Out Of CSV Using Comparison Operators.
Using the import-csv cmdlet with where-object and parse the data out of the CSV file using comparison operators:

-eq Equal
-ne Not equal
-ge Greater than or equal
-gt Greater than
-lt Less than
-le Less than or equal
-like Wildcard comparison
-notlike Wildcard comparison

Logical operators
-and Logical And

Examples:

$data= import-csv $file
$results= $data | where {$_.Username -eq "Sam Blackman"}
$results

$data= import-csv $file
$results= $data | where {$_.Username -like "*Sam*"}
$results

$data= import-csv $file
$results= $data | where {$_.ID -le "5"}

$data= import-csv $file
$results= $data | where {($_.Location -notlike "Seattle") -and ($_.Location -notlike "Washington DC")}
$results

Рекомендации по теме
Комментарии
Автор

That was very helpful - thanks for putting your commands in the description above. Very clear and easy to comprehend.

robertjones
Автор

I'm looking to import from .csv - strip out numbers from columns that are varchar - and export to excel so I can aggregate those columns. How would you approach that?

robertjones
Автор

Good content but hard to see your screen. Too small and blurry.

TechWaltMD
Автор

Can you please tell me how to get individual data like “The id of a username “ instead of all the data??

reyankachattaraj
Автор

How do get count of results ex: 'occupation like CEO' . Expecting results look like occupation 2

karthee