Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file access time vs. storage memory

Status
Not open for further replies.

eve25

Programmer
Feb 9, 2004
32
US
Hi folks,
I have to process about 10 files and to make the data from these files (let's say input file) available in another format (let's say output file). So basically I take the data, manipulate it and print it in another file. Each input file contains about 60 records, each one containing some information lines and 600 numbers. For the moment I have an array for each record containing the data, and I have currently 2 possibilities (I think) create an hash to have acces to each record of one input file and make the ouput file after processing all the file or printing my data in the output file directly while I am in each record loop. I was thinking the second one would be better but still the access time to the file may be quite big!!!
What do you think would be better? Any advise would be great!
Thanks,
Eve, (Still a french girl lost in California..hoping I am understandable!)
Thanks!
 
For 2 reasons I would say try to write the file in once:
- file access costs time
- repeatable file access increases the risk of permission problems (suppose someone opened the file while you are working in it). A 1 time writing is slightly more robust I think.

But maybe someone can give good reasons for the other?

It would be horrible to be able to make a decision right? ;)
 
eve,
60 records isn't big. If you're worried about file collisions have a look at flock, so you can work with impunity, or copy a temporary version of the file you're working on, and read that instead of the active file, and delete when you're finished

HTh
--Paul
 
ouahou, it is quick!
I don t care about permission, only this program would access this file, but I do care about the time file access costs!
anybody would say the first solution?
anyway, thanks a lot for these answers guys!
have a wonderful day!
Eve

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top