How to merge two files like the following



I have two text files.

I want to merge them together as follows:

File1.txt

SCREEN,
PROGRAM,
FIELD1,
VALUE1,
FIELD2,
VALUE2,
FIELD3,
VALUE3,


================================


File2.txt

S1,P1,F11,V11,F12,V12,F13,V13
S2,P2,F21,V21,F22,V22,F23,V23
....
....



Now when I merge the two files together I want the following file:


File3.txt

SCREEN, S1
PROGRAM,P1
FIELD1,F11
VALUE1,V11
FIELD2,F12
VALUE2,V12
FIELD3,F13
VALUE3,V13
SCREEN, S2
PROGRAM,P2
FIELD1,F21
VALUE1,V21
FIELD2,F22
VALUE2,V22
FIELD3,F23
VALUE3,V23

=======================================================

I want a generic script that can merge file1.txt and file2.txt to
generate file3.txt

I want a script that can take a template of File1.txt as follows:

SCREEN, <<S>>
PROGRAM, <<P>>
FIELD1, <<C1>>
VALUE1, <<C2>>
FIELD2, <<C3>>
VALUE2, <<C4>>
FIELD3, <<C5>>
VALUE3, <<C6>>

=======================================================

and the file2.txt to identify what goes to <<S>>, <<P>>
in the following form:


File2.txt
<<P>>,<<S>>,<<C1>>,<<C2>>,<<C3>>,<<C4>>,<<C5>>,<<C6>>
S1,P1,F11,V11,F12,V12,F13,V13
S2,P2,F21,V21,F22,V22,F23,V23
....
....

=======================================================


So I want a generic VB Script that can accept three arguments for
file1, file2 and file3 and can merge the template of file1 to the
contents in file2 to be substituted in file1 to generate file3.

Appreciate if any of you can kindly share a code which most of you
would have faced with such a similar problem.

I thought of using MS Word but instead of file2 my data can come from
anydata source like a database and the amount of merge I need to do is
huge and file3 the output file as to be a text file. Using word for
this is a overkill it solves some problem and creates another.

To keep it simple I want the whole merge process in VBScript.

Appreciate if you could kindly share the VBScript code.

Thanks
Karen

.



Relevant Pages

  • Re: More than one vbs file
    ... > I know I'm using wsh. ... individuals have the access necessary to edit our logon script. ... If you have a main logon script that you want to invoke vbscript routines ... execute the vbscript code in file "BillyBob.vbs" and the second executes the ...
    (microsoft.public.scripting.vbscript)
  • VBScript code execution on the "read side"
    ... I have problem with VBScript code. ... When I place the code in Click event of any button on "write side" of the script then it is executed. ... how to lock filled controls when a receiver is getting the form (he shouldn't be able to edit the form)? ...
    (microsoft.public.office.developer.outlook.forms)
  • Re: Problem with script encoder
    ... customization for an application that invokes this host to run ... >> I've got a vbscript code that works fine when left unencoded. ... >> encoding with Windows Script Encoder, I get a bunch of "type ... apparently on all SUBs using global variables. ...
    (microsoft.public.scripting.vbscript)
  • Re: Generic Script Resource error
    ... I will post my script to the other ... Can I customize the environment that the generic script ... >> I have been trying to use a generic script resource to control MS ...
    (microsoft.public.windows.server.clustering)
  • Re: Problem with script encoder
    ... > I've got a vbscript code that works fine when left unencoded. ... > encoding with Windows Script Encoder, I get a bunch of "type ... Post the actual screnc.exe command line you used to encode the script. ...
    (microsoft.public.scripting.vbscript)