Count File Rows with PowerShell

ByRob Peledie

Count File Rows with PowerShell

Very quick post (more so I don’t forget how to do this!)

Had a CSV file which I knew had a lot of rows!….. more than excel could handle to open, so I wanted to know the exact number, but without opening.

PowerShell to the rescue:

$lines = 0
$fileReader = New-Object IO.StreamReader 'NAME_OF_YOUR_CSV.csv'
while ($fileReader.ReadLine() -ne $null)
echo $lines

Result for me….. after a short while 🙂 4,366,151

About the author

Rob Peledie administrator

Leave a Reply