Count File Rows with PowerShell

By365KAdmin

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)
{
	$lines++
}
$fileReader.close()
echo $lines

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

About the author

365KAdmin administrator

1 Comment so far

Count File Rows with PowerShell – 365Knowledge – Dynamics365BlogsPosted on5:17 pm - May 7, 2019

[…] Count File Rows with PowerShell […]

Leave a Reply