INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

replace data in a file from data in another text file

replace data in a file from data in another text file

replace data in a file from data in another text file

(OP)
Hi everyone!

I am trying to create a batch of files from a master xml file. Everything will be the same except for 2 fields that I need to dynamically change for each created file. The data can be put in a data file to read from or any other suggestions on how to get these values to be read by the awk program?

I have the code to create the xml files and now i'm looking how to find and replace the 2 data values with specific values.

Example:

original xml file:

<Invoice>
<InvoiceNum>ABC</InvoiceNum>

<InvoiceLine>
<InvoiceLineNumber>0001</InvoiceLineNumber>

I would need to replace these values with values from a text value..

data file:

ABC, 123
DEF, 456

Thanks!

RE: replace data in a file from data in another text file


You are not the only one working on this problem, it seems the whole class is wants the solution.
You should at least try to solve this on your own and perhaps someone will help you if you get stuck!
reading

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

RE: replace data in a file from data in another text file

(OP)
I am trying to read the file into an array. And then when i loop through the file creation, i can pull the array data as my substitute.

I'm new to this and if anyone has a simple example i can use to read a file into an array that would get me started.

RE: replace data in a file from data in another text file

(OP)
ok, thanks! I will do a search on that!

RE: replace data in a file from data in another text file

Quote (Sarah)

I am trying to read the file into an array. . .
Hi Sarah,

Sometimes the xml file does not have embedded line feed's (new line) that would separate the text in lines, but rather the whole xml is in one huge line.

Therefore, unless the xml file is formatted with line-feed's, reading the file into an array will not help at all.

Check out this post, perhaps it will help.
flowerface

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

RE: replace data in a file from data in another text file

(OP)
the file to be read in will just be a standard data text. It can be delimited by spaces, comma's etc.

The file that needs to be created/updated by the data will be the xml files.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close