Hi
I'm trying to extract rows that match a pattern (3 characters and 8 digits) from a csv file and output them to a new csv
an example of the csv file is below
user_id status
MCN18158364 active
901658 active
W00054 active
MCN17125917 active
I'm trying to extract rows that match a pattern (3 characters and 8 digits) from a csv file and output them to a new csv
Code:
#Import the CSV file with all the data.
$csv = Import-CSV J:\CanvasData\users_utf8nobom.csv
#Process the CSV file one row at a time
foreach ($row in $csv) {
#Each column is accessed using the column header.
#We can use the -not operator to specify 'doesn't match'.
if ($row.user_id -eq "\b[\D[3}\d{8}]\b")
{
#... Export that row to a new CSV file.
$row | Export-CSV J:\Temp\teacherlist.csv -Append -NoTypeInformation
}
}
an example of the csv file is below
user_id status
MCN18158364 active
901658 active
W00054 active
MCN17125917 active