View Single Post
Old Jan 24th, 2005, 11:01 AM   #1
Novice
Newbie
 
Join Date: Jan 2005
Posts: 1
Rep Power: 0 Novice is on a distinguished road
Repetitive replacing sections of text files

I am a novice with programming, however it is about time I learnt as it is longwinded and time consuming, not to mention boring doing the same thing time and time again manually. So I am hoping someone can provide me with a leg up.

I have two text files. One contains information in sections, which is called textfile-load.txt say.

Like

SET 1
11 11 11 11
11 11 11 11
11 11 11 11

SET 2
22 22 22 22
22 22 22 22
22 22 22 22

The other text file (text.dat) is a string of commands for a mathematical program I use to solve. Now within this text file I wish to replace the commands for SET 1 with SET 2.

So I want to replace the part with SET 1 in the text.dat file with the SET 2 section of the textfile-load.txt.

So I want to replace in the text.dat file

11 11 11 11
11 11 11 11
11 11 11 11

with

22 22 22 22
22 22 22 22
22 22 22 22

with the information obtained from textfile-load.txt


there is also another line that requires replacing somewhere else in the DAT file which for example will say

SET 1, which I would want to replace with SET 2.

Once I have replaced it, I want to save the file under a different file name.

I have avaliable to use MAPLE/MATLAB and I can download Awk, however I haven't the foggiest which language to write it in, or even how to start.

Help/Advice would be appreciated.
Novice is offline   Reply With Quote