Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[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 <ltashi32@hotmail.com>
To   <statalist@hsphsun2.harvard.edu>
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: njcoxstata@gmail.com
> To: statalist@hsphsun2.harvard.edu
>
> 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 <ltashi32@hotmail.com> 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: njcoxstata@gmail.com
> >> To: statalist@hsphsun2.harvard.edu
> >>
> >> That's not a fix to anything. It's not even legal.
> >>
> >> Nick
> >>
> >> On Thu, Aug 16, 2012 at 7:15 PM, tashi lama <ltashi32@hotmail.com> 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index