How to Modify Specific chars in text file

Hello Guys!

I am new in the forum, and I have been learning a lot from the answers to the rookie questions. Thank you so much for that!!

I can’t figure out how to replace date vars from a text file with my own variables. I already burned my chances with all kind of approaches from this forum.

I have this text like a .mxl

set timestamp on;
spool sjwur on to 'OTU.err';

login 'user' 'pass' on 'qwerty.oracleoutsourcing.com:3005';

alter database 'OTU'.'OTU' set variable 'Last_Week' '"29-18"';
alter database 'OTU'.'OTU' set variable 'This_Week' '"30-18"';
alter database 'OTU'.'OTU' set variable 'Next_Week' '"31-18"';
alter database 'OTU'.'OTU' set variable 'Forecast_Week' '"37-18"';

logout;

And I have an array of Strings with the new dynamic variables in the same format Week-YY like 32-18.

How can I do this in a efficient way?

Thank you so much!!

So you have an array like {“WW-YY”, “WW-YY”, “WW-YY”, “WW-YY”} (different elements) and you want to replace it in the file in the four rows that you have shown.

Am i getting you correct?

1 Like

Hello kaderms!

Yes exacly, it sounds so easy but I still can’t make it.

Create a “templateFile.txt” which looks like this :

set timestamp on;
spool sjwur on to 'OTU.err';

login 'user' 'pass' on 'qwerty.oracleoutsourcing.com:3005';

alter database 'OTU'.'OTU' set variable 'Last_Week' '"{0}"';
alter database 'OTU'.'OTU' set variable 'This_Week' '"{1}"';
alter database 'OTU'.'OTU' set variable 'Next_Week' '"{2}"';
alter database 'OTU'.'OTU' set variable 'Forecast_Week' '"{3}"';

logout;

Read the text file using Read text file activity.
On the txtContent do this :

String.Format(txtContent, {"29-18", "30-18", "31-18", "37-18"})

you can write it to your file format using Write text file activity.

1 Like

No way! You are a genius!! I am so happy! I lost like 6 hours trying different things, I really appreciate it!

1 Like

I’ve been there too :laughing: Now you’ve become the genius on this :raised_hands:t2:

1 Like