Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: Use Regular Expressions to replace words/strings of characters in a text file


From   tashi lama <[email protected]>
To   <[email protected]>
Subject   RE: st: Use Regular Expressions to replace words/strings of characters in a text file
Date   Thu, 16 Aug 2012 19:58:48 +0000

I am so confused and more I read, it only gets worse. So, in order to not overlap and write on a clean sheet, I need to say *file open handle using tt.xml, write replace*. The help file for file says and i quote "When a file is opened write and the replace option is also specified, it does not matter whether the file already exists; the existing file, if any, is erased beforehand". This is what I need. I have an existing file but it will erase the file before I start writing. The problem and quite contradictory(unless I am not understanding) is I need a *file open read line* which needs option read in the file open. But the help file says replace and append are allowed only when the file is opened for write (which does not include read write). I want a line to be read and written in a clean sheet. Note( the actual commands are preceded and suffixed by * to avoid confusion). 

Thanx, 
Tashi 
----------------------------------------
> Date: Thu, 16 Aug 2012 20:41:30 +0100
> Subject: Re: st: Use Regular Expressions to replace words/strings of characters in a text file
> From: [email protected]
> To: [email protected]
>
> The only legal construct with -file close- is
>
> file close {handle|_all}
>
> I can't see any reason to suppose that opening any other file is
> necessary, nor that it would be useful.
>
> Nick
>
> On Thu, Aug 16, 2012 at 7:42 PM, tashi lama <[email protected]> wrote:
> > well, it writes the line if it finds "Cell" in the line except that it overlaps in the old file tt.xml. I guess I need to open another empty file and dump the line there.
> >
> > ----------------------------------------
> >> Date: Thu, 16 Aug 2012 19:18:40 +0100
> >> Subject: Re: st: Use Regular Expressions to replace words/strings of characters in a text file
> >> From: [email protected]
> >> To: [email protected]
> >>
> >> That's not a fix to anything. It's not even legal.
> >>
> >> Nick
> >>
> >> On Thu, Aug 16, 2012 at 7:15 PM, tashi lama <[email protected]> wrote:
> >> > Thanx...I forgot to put the increment in the while loop
> >> > while ...{
> >> >
> >> > ....
> >> > file close myfile line
> >> > }
> >> >
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/ 		 	   		  
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index