number of rows

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
is there any give variavle that returns number of rows of given file?

Re: number of rows

Piotr Wolski wrote:

Quoted text here. Click to load it

try this:

$filename = "/myfile.txt";
$fhandle = file($filename);
$numrows = count($fhandle);

Re: number of rows

Quoted text here. Click to load it

 Do you want the number of lines in a file? If so open the file, loop through
the lines keeping a counter, and then close it.

 Or having recently read a similar thread on a Perl newsgroup, it might be
worth considering using the 'wc' command, if you're on Unix. I don't tend to
like spawning external programs within a script, but it's hard to argue with
the benchmarks for larger files.

--          /

Site Timeline