is there any give variavle that returns number of rows of given file?
number of rows
Collapse
This topic is closed.
X
X
-
Piotr WolskiTags: None -
neur0maniak
Re: number of rows
Piotr Wolski wrote:
[color=blue]
> is there any give variavle that returns number of rows of given file?[/color]
try this:
$filename = "/myfile.txt";
$fhandle = file($filename) ;
$numrows = count($fhandle) ;
-
Andy Hassall
Re: number of rows
On Thu, 15 Jul 2004 16:49:24 -0500, Piotr Wolski <wolski@cs.purd ue.edu> wrote:
[color=blue]
>is there any give variavle that returns number of rows of given file?[/color]
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.
--
Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Comment
Comment