Re: input a section of a large file [message #171662 is a reply to message #171659] |
Fri, 14 January 2011 19:31 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 14/01/11 18:25, richard wrote:
> On Fri, 14 Jan 2011 10:41:19 -0700, richard wrote:
>
>> Just being curious.
>> Is it possible in php to acquire information from a file in part, rather
>> than retrieving the whole file?
Yes, you can read a line at a time.
>> I have a series of tables that I would prefer not showing up on the main
>> page when loaded. When the user clicks the link, the tables would appear.
>> Rather than uploading a thousand small files, I'd rather upload a dozen or
>> so files and retrieive the tables as needed.
If you want to use text files that contain data (for example csv data)
that you will use to create tables, it would probably be best to have a
separate file containing the data for each table that you wish to create.
You could also write a script off-line to create html tables that are
output as included php files. This would save the resources involved in
repeated conversion to html using php of static data in text files.
> Perhaps to clarify a little, I am thinking of something in the way of using
> file_get_contents as a means to open the file, then retrieving the
> particular item I want within that file.
If a file contains data for lots of tables, how will you know where in
the file the data for the table that you want is?
Where are you going to store the offsets? And what implications does
that have for things that need to get updated when the table data files
are changed?
What happens when you discover that all your offsets are wrong due to
differences in cr/lf handling?
Rgds
Denis McMahon
|
|
|