Skip to main content
Post a question

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id : J1Ioye7ipQ6vhJDf7ZJ4+O
Dynamics 365 Community / Blogs / CRMConsult.co.uk / Count File Rows with PowerS...

Count File Rows with PowerShell

Community Member Profile Picture Community Member Microsoft Employee

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

Comments

*This post is locked for comments