comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Fast editing of text file?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Fast editing of text file? [message #44477 is a reply to message #44476] Wed, 15 June 2005 19:55 Go to previous messageGo to previous message
Andrew Cool is currently offline  Andrew Cool
Messages: 219
Registered: January 1996
Senior Member
t_314159@yahoo.com wrote:
> Hi,
> I have a text file that I must access many times during program
> execution (1000's of times, really!) and I *always* only need to change
> the the text on the 12th line of the file. My question, how to
> efficiently access and alter the text of ONLY the 12th line without
> altering even a single space or comma on any of the rest of the lines?
> And did I mention fast since i've got to loop through this many times?


If lines[0:10] and lines[12:*] don't change, why not hold those
permanently
in memory as two string arrays, array_top and array_bottom.

Concoct Line 12 with your 3 new numbers,
and then printf to a new version of the file :-

printf,outlun, array_top ; lines 1..11
printf,outlun, line12 ; line 12
printf,outlun, array_bottom ; lines 13..end of file

This way you've only got 1 read, at the very start of your program, and
then 1 write per change of numbers.

Sounds easy.

Andrew C.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: How does IDL find functions?
Next Topic: ASCII read problem

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

Current Time: Thu Oct 09 23:20:48 PDT 2025

Total time taken to generate the page: 0.80126 seconds