I receive a CSV File everyday that has information I need, but i have to filter rows base on a different criteria for each row.
eg csv.
Name,Age,Date,Code
John,22,12/12/2020,5
Smith,16,12/01/2021,2
Jake,27,1/01/2020,1
Alice,18,2/02/2019,4
Fort,27,2/09/2021,2
Kevin,26,22/09/2019,5
I would like:
My Result should be
Name,Age,Date,Code
Jake,27,1/01/2020,1
Fort,27,2/09/2021,2
$csv = @"
Name,Age,Date,Code
John,22,12/12/2020,5
Smith,16,12/01/2021,2
Jake,27,1/01/2020,1
Alice,18,2/02/2019,4
Fort,27,2/09/2021,2
Kevin,26,22/09/2019,5
"@ | ConvertFrom-Csv
$csv.where{
($_.Age -le 18,
[datetime]::ParseExact($_.Date, 'd/MM/yyyy', $null) -ge [datetime]::ParseExact('01/01/2020', 'dd/MM/yyyy', $null),
$_.Code -eq 5)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.