Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Line Count in CSV File 1

Status
Not open for further replies.

cmhunt

Programmer
Joined
Apr 17, 2001
Messages
119
Location
GB
Is there a function to count the amount of lines in a CSV files without manually looping through the whole file and counting them?? I have looked on php.net and couldn't seem to find anything.

Thanks

Chris
 
You could read the file using the file() command.
That puts it into an array where each element is one line (with the line break still attached).
The do a count($myArray) to get the number of lines.
 
You might also be able to invoke an external program to do the job.

For example, Linux usually is installed with a program called "wc", which can tell you the number of lines in a file.

Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top