Note that there are some explanatory texts on larger screens.

plurals
  1. POReplace Multiple lines in Jython
    primarykey
    data
    text
    <p>I have written a small program to replace a set of characters , but i also want two or more replace command in a single program . </p> <p>Apart from it i also want to add an bracket after random set of characters.</p> <p>This is my Program </p> <pre><code>file_read=open('&lt;%=odiRef.getOption("READ")%&gt;/EXPORT.XML','r') file_write=open('&lt;%=odiRef.getOption("READ")%&gt;/EXPORT_1.XML','w') count_record=file_read.read() while count_record : s=count_record.replace('&lt;Field name="ExeDb"type="java.lang.String"&gt;&lt;![CDATA[S]]&gt;&lt;/Field&gt;','&lt;Field name="ExeDb" type="java.lang.String"&gt;&lt;![CDATA[W]]&gt;&lt;/Field&gt;') file_write.write(s) t=count_record.replace('&lt;Field name="Txt" type="java.lang.String"&gt;&lt;![CDATA[','&lt;Field name="Txt" type="java.lang.String"&gt;&lt;![CDATA[TRIM(') file_write.write(t) count_record=file_read.read() print s file_read.close() file_write.close() </code></pre> <p>As you can see when i try to do with read line i get two lines in the final file.</p> <p>1) I want both the replace command to work but with only single file. </p> <p>2) Also is there is any way to read and write in a single file , i dont know why r+ was not working properly.</p> <p>3) I also want to modify the line </p> <pre><code>t=count_record.replace('&lt;Field name="Txt" type="java.lang.String"&gt;&lt;![CDATA[','&lt;Field name="Txt" type="java.lang.String"&gt;&lt;![CDATA[TRIM(') </code></pre> <p>to somethings like </p> <pre><code>t=count_record.replace('&lt;Field name="Txt" type="java.lang.String"&gt;&lt;![CDATA[','&lt;Field name="Txt" type="java.lang.String"&gt;&lt;![CDATA[TRIM($$$) ') </code></pre> <p>where $$$ represents words or character present in the source File.</p> <p>in short adding ) close bracket at the end , irrespective of any number of words or character after opening bracket .</p> <p>Thanks so much for all your help. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload