FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Going back to a previous line in a CSV file
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Going back to a previous line in a CSV file [message #170176 is a reply to message #170147] Sat, 16 October 2010 17:52 Go to previous messageGo to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma:
Senior Member
pereges wrote:

> I guess what I'm trying to do here is move back and forth between the
> file which is so much more difficult with flat files.

It is rather easy to do (as long as you are not changing anything) if in the
first pass you store in an array for each line the byte offset that ftell()
tells you, to which you can then fseek() (I am currently doing this to
continue processing a large CSV file after a PHP/DB connection timeout).

Contrary to what Michael Fesser said, this is rather independent of the line
length (RTFM on fgets() and fgetcsv() for details.) There might even be a
built-in or PEAR class for dealing with flat files.

> I've even considering dumping this CSV data in a mysql table and then
> I can process the data easily with query statements.

You could load all the data into an array and work with that probably even
more easily. Look into array_filter(), for example.


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to Hide browser status bar Message from client
Next Topic: Mesothelioma
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 21:33:48 GMT 2024

Total time taken to generate the page: 0.04125 seconds