Re: Deleting charachter from a text file
- To: mathgroup at smc.vnet.net
- Subject: [mg68186] Re: Deleting charachter from a text file
- From: "Giacomo Ciani" <giacomo.ciani at gmail.com>
- Date: Thu, 27 Jul 2006 05:30:12 -0400 (EDT)
- References: <ea722g$k1n$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Thanks, but this solution is not feasable for me. I'm running a simulation and one of the reason of writing directly on the file "step by step" the results is not to fill the memory, because I'm genearting a lot of data. Just for curiosity, I'm going to explain the problem in details... actually, what i'm doing is something like: OpenWrite[file] WriteString["{{zeroArray}"] Do[ ...calculations... WriteString[file,","] Write[file, stepResultArray] ] WriteString["}"] taht is, I'm writing a list of "resultArrays". But as you can see, my list is not coled by the "}" character till the simulation has ended. What I would like to do is to close the list with the "}" at every step, and the on the next step (after "...calculations...") reopen it, add the new element, and close it again. This way I should be able to import the file in another Mathematica program at any time, even if the simulation is not ended... Bye, and thanks again Giacomo Jens-Peer Kuska wrote: > Hi, > > you must open the file, read the contents in the memory > and save the changed contents. > > Any editor keep the file contents in memory > (atleast partial) and you should do this also. > > Regards > Jens > > "Giacomo Ciani" <giacomo.ciani at gmail.com> schrieb > im Newsbeitrag news:ea4jva$sck$1 at smc.vnet.net... > | Hello, > | > | I'm using direct access to text files to save > data my program > | generates. So I use a syntax like: > | > | OpenWrite[file]; > | WriteString[file,"text"]; > | ... > | WriteString[file,"text2"]; > | ... > | Ecc... > | Close[file] > | > | I would like to be able to remove some > characters (i.e. the last two > | characters) from the file before writing new > ones (as an example, I > | could need to remove the "xt" character of the > word "text" before > | writing the word "text2"). How can I accomplish > this? I can't find any > | function in the documentation to remove > characters from a file... > | > | Thanks > | > | Giacomo > |