Powershell to count columns in a file
问题 I need to test the integrity of file before importing to SQL. Each row of the file should have the exact same amount of columns. These are "|" delimited files. I also need to ignore the first line as it is garbage. If every row does not have the same number of columns, then I need to write an error message. I have tried using something like the following with no luck: $colCnt = "c:\datafeeds\filetoimport.txt" $file = (Get-Content $colCnt -Delimiter "|") $file = $file[1..($file.count - 1)]