Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
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
Old May 20th, 2005, 2:41 PM   #2
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
Rep Power: 4 mackenga is on a distinguished road
You've made an effort to make this question clear, but I for one can't make head nor tail of it. Sorry.
mackenga is offline   Reply With Quote
Old Jun 17th, 2005, 9:07 AM   #3
jim mcnamara
Hobbyist Programmer
 
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4 jim mcnamara is on a distinguished road
You know, there are simple command line tools in unix that will do this with one line.
Some are available for Windows.

What OS are you using?
jim mcnamara is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:40 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC