This allows you to view file as an array and handles the details for you. The file isn't automatically all read into memory and so can work on large files. Could be some performance issues or not in your app.
Update: As another thought, you could reconsider your approach. A common way is to just log the data by appending to a file. Then have some other program that analyzes the log data to make reports. Of course this depends upon how many lines this log file will have, etc...
Another update: If performance is a consideration, appending to an existing file is pretty much the fastest way to write something to the disk. And this is essentially independent of the file size. Appending data to a 1K file is same cost as appending data to a 1GB file. If your program spews out say 1,000 lines per hour, that's only 24,000 lines per day. Not much data in the scheme of things, 10x that much is not that much. It sounds to me like you just need daily stats. Even on Windows there is the concept of a "chron" job and you can also start tasks at different priorities (from a .bat file, use the "start" command instead of just typing in the executable name). But I don't think you need that. I mean crunching through say a 250K line log file to make a report is easy.
My advice is: do something simple that functionally does what you want. If that doesn't "work" for performance reasons, then get more complex.
In reply to Re^3: Replace current line in while loop
by Marshall
in thread Replace current line in while loop
by walkingthecow
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |