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

  Рет қаралды 15,734

Lockard

Lockard

Күн бұрын

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:
$file= "C:\Users\Nick\Downloads\data.csv"
$data= import-csv $file
$results= $data | where {$_.Username -eq "Sam Blackman"}
$results
$file= "C:\Users\Nick\Downloads\data.csv"
$data= import-csv $file
$results= $data | where {$_.Username -like "*Sam*"}
$results
$file= "C:\Users\Nick\Downloads\data.csv"
$data= import-csv $file
$results= $data | where {$_.ID -le "5"}
$results |ft | out-file test13.txt
$file= "C:\Users\Nick\Downloads\data.csv"
$data= import-csv $file
$results= $data | where {($_.Location -notlike "Seattle") -and ($_.Location -notlike "Washington DC")}
$results
This video is brought to you by www.lockard.it

Пікірлер: 7
@robertjones5669
@robertjones5669 3 жыл бұрын
That was very helpful - thanks for putting your commands in the description above. Very clear and easy to comprehend.
@robertjones5669
@robertjones5669 3 жыл бұрын
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?
@reyankachattaraj
@reyankachattaraj 4 жыл бұрын
Can you please tell me how to get individual data like “The id of a username “ instead of all the data??
@9000fail
@9000fail 4 жыл бұрын
you can pipe to select-object or use dot notation or create a object array using pscustomobjects, etc.
@karthee86
@karthee86 5 жыл бұрын
How do get count of results ex: 'occupation like CEO' . Expecting results look like occupation 2
@VeganSmasher
@VeganSmasher 4 жыл бұрын
$file= "C:\Users\Nick\Downloads\data.csv" $data= import-csv $file $results= $data | where {$_.Occupation -like "CEO"} ($results).Count
@TechWaltMD
@TechWaltMD 5 жыл бұрын
Good content but hard to see your screen. Too small and blurry.
PowerShell Intermediate Tutorial 5 : CSV Files [Intermediate]
13:35
JackedProgrammer
Рет қаралды 9 М.
How it feels when u walk through first class
00:52
Adam W
Рет қаралды 23 МЛН
Good teacher wows kids with practical examples #shorts
00:32
I migliori trucchetti di Fabiosa
Рет қаралды 13 МЛН
How to whistle ?? 😱😱
00:31
Tibo InShape
Рет қаралды 15 МЛН
PowerShell ForEach-Object
16:14
Shane Young
Рет қаралды 51 М.
PowerShell ForEach and CSV File Tutorial
15:01
Jeff Brown Tech
Рет қаралды 618
PowerShell Arrays Introduction
19:20
Shane Young
Рет қаралды 54 М.
Viral Video of a Man's Crazy Job Interview
16:02
Darryl Vega TV
Рет қаралды 1,4 МЛН
PowerShell Tutorials : Editing CSV files (Adding columns, editing data)
14:37
Working with the PowerShell Pipeline
15:17
TechThoughts
Рет қаралды 90 М.
Getting Started with PowerShell Parameters
9:32
Jeff Brown Tech
Рет қаралды 369
Comparing data in PowerShell
6:31
David Dalton
Рет қаралды 3,3 М.
PowerShell 7 Tutorials for Intermediates #6 : CSV Files
17:10
JackedProgrammer
Рет қаралды 2,8 М.
PowerShell: Compare two excel files and highlight differences
4:55
AIP IT Solutions
Рет қаралды 4,6 М.
How it feels when u walk through first class
00:52
Adam W
Рет қаралды 23 МЛН