-2

I have a csv file with ID numbers and want to delete a row if that ID is not completely a number.

Example:

0001, jeff, smith

0abc, john, jones

I would like the "0abc, john, jones" row removed from the csv file.

Chris
  • 35
  • 1
  • 5

1 Answers1

0

If you just had that in your text file and nothing else this would work

Import-Csv -path c:\temp\data.csv -Header ID,First,Last | 
    Where-Object{$_.ID -match '^\d+$'} | 
    Export-CSV -Path c:\temp\newfile.csv

If you have issue with this please look at the following references

Community
  • 1
  • 1
Matt
  • 45,022
  • 8
  • 78
  • 119