|
List Info
Thread: Lines in a file
|
|
| Lines in a file |
  United States |
2007-10-15 12:49:05 |
What is the simplest, cheapest way to find out how many
lines are in a
file opened with fopen?
I've got a cli script that reads a very long file and I want
to give
progress feedback.
Cheers,
Trevor
--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development
staff at 360 PSG. An enterprise application development
company utilizing open-source technologies for todays
small-to-medium size businesses.
For information or project assistance please visit :
http://www.360psg.com
You received this message because you are subscribed to the
Google Groups "Professional PHP Developers"
group.
To post to this group, send email to Professional-PHP googlegroups.com
To unsubscribe from this group, send email to
Professional-PHP-unsubscribe googlegroups.com
For more options, visit this group at http:
//groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Lines in a file |
  United States |
2007-10-15 13:09:59 |
Maybe you could count the number of new lines?
<?PHP
$text = <<<EOT
This is a test.
Should be 2 lines.
EOT;
$numlines = count(split("n", $text));
echo $numlines;
?>
--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development
staff at 360 PSG. An enterprise application development
company utilizing open-source technologies for todays
small-to-medium size businesses.
For information or project assistance please visit :
http://www.360psg.com
You received this message because you are subscribed to the
Google Groups "Professional PHP Developers"
group.
To post to this group, send email to Professional-PHP googlegroups.com
To unsubscribe from this group, send email to
Professional-PHP-unsubscribe googlegroups.com
For more options, visit this group at http:
//groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Lines in a file |
  United States |
2007-10-15 13:17:59 |
The file is about 40 gigabytes in size.
On Oct 15, 2:09 pm, "webmas... hpiracing.com"
<webmas... hpiracing.com> wrote:
> Maybe you could count the number of new lines?
> <?PHP
>
> $text = <<<EOT
> This is a test.
> Should be 2 lines.
> EOT;
>
> $numlines = count(split("n",
$text));
> echo $numlines;
>
> ?>
--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development
staff at 360 PSG. An enterprise application development
company utilizing open-source technologies for todays
small-to-medium size businesses.
For information or project assistance please visit :
http://www.360psg.com
You received this message because you are subscribed to the
Google Groups "Professional PHP Developers"
group.
To post to this group, send email to Professional-PHP googlegroups.com
To unsubscribe from this group, send email to
Professional-PHP-unsubscribe googlegroups.com
For more options, visit this group at http:
//groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Lines in a file |
  United States |
2007-10-15 13:53:15 |
Yeesh, why? Something that big, you'd think it would belong
in a SQL
dbase of some sort.
With a file that size, any option will be a slow options...
=(
--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development
staff at 360 PSG. An enterprise application development
company utilizing open-source technologies for todays
small-to-medium size businesses.
For information or project assistance please visit :
http://www.360psg.com
You received this message because you are subscribed to the
Google Groups "Professional PHP Developers"
group.
To post to this group, send email to Professional-PHP googlegroups.com
To unsubscribe from this group, send email to
Professional-PHP-unsubscribe googlegroups.com
For more options, visit this group at http:
//groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Lines in a file |
  United States |
2007-10-15 13:54:51 |
Yeesh, why? Something that big, you'd think it would belong
in a SQL
dbase of some sort.
With a file that size, any option will be a slow option...
=(
--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development
staff at 360 PSG. An enterprise application development
company utilizing open-source technologies for todays
small-to-medium size businesses.
For information or project assistance please visit :
http://www.360psg.com
You received this message because you are subscribed to the
Google Groups "Professional PHP Developers"
group.
To post to this group, send email to Professional-PHP googlegroups.com
To unsubscribe from this group, send email to
Professional-PHP-unsubscribe googlegroups.com
For more options, visit this group at http:
//groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Lines in a file |
  United States |
2007-10-15 19:35:53 |
Exactly. I am converting ragged-right text files to SQL.
Perhaps I could divide the total bytes of file by the bytes
in the
first line of text and use that as a progress indicator?
Anyone know how to get the bytes of a string? It's all
ASCII text and
spaces... feel free to embarrass me by pointing out how easy
this is.
On Oct 15, 2:54 pm, "webmas... hpiracing.com"
<webmas... hpiracing.com> wrote:
> Yeesh, why? Something that big, you'd think it would
belong in a SQL
> dbase of some sort.
>
> With a file that size, any option will be a slow
option... =(
--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development
staff at 360 PSG. An enterprise application development
company utilizing open-source technologies for todays
small-to-medium size businesses.
For information or project assistance please visit :
http://www.360psg.com
You received this message because you are subscribed to the
Google Groups "Professional PHP Developers"
group.
To post to this group, send email to Professional-PHP googlegroups.com
To unsubscribe from this group, send email to
Professional-PHP-unsubscribe googlegroups.com
For more options, visit this group at http:
//groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---
|
|
[1-6]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|