<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>How to parse InputFile to generate OutputFile?</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3395" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN lang=en-us><FONT face=Arial
size=2>Hi,</FONT></SPAN> <BR><SPAN lang=en-us><FONT face=Arial size=2>I am new
to Python and need your help to generate an output file as explained
below.</FONT></SPAN> </DIV>
<P><FONT face=Arial><FONT size=2><SPAN lang=en-us>I need to generate an output
text file based on the input text file data<SPAN class=869260721-17092008><FONT
color=#0000ff> .</FONT></SPAN></SPAN></FONT></FONT></P>
<P><FONT face=Arial><FONT size=2><SPAN lang=en-us><SPAN
class=869260721-17092008> </SPAN></SPAN><SPAN lang=en-us><B>Input.txt
contents:</B></SPAN></FONT></FONT> <BR><SPAN lang=en-us><FONT face=Arial
color=#800000 size=2>('844 - Open File Message', '011 - System Trace Audit
Number: 823301', '012 - Local Time: 033543', '013 - Local Date: 0821', '024 -
Function Code: 861')</FONT></SPAN></P>
<P><SPAN lang=en-us><FONT face=Arial color=#800000 size=2>('844 - Open Service
Message', '011 - System Trace Audit Number: 000003', '012 - Local Time: 033543',
'013 - Local Date: 0821', '024 - Function Code: 865')</FONT></SPAN></P>
<P><FONT color=#800000><SPAN lang=en-us><FONT face=Arial size=2>('345 -
Remittance Open Message', '011 - System Trace Audit Number: 023301', '026 -
Upload Control: 000001')</FONT></SPAN> <BR><SPAN lang=en-us><FONT face=Arial
size=2>('146 - Message', '02 - Primary Account Number is: 6751469991140620','10
- System Trace Audit Number2:</FONT><B> <FONT face=Arial
size=2>369325</FONT></B><FONT face=Arial size=2>', 'FF47 - Security of the
Internet: ')</FONT></SPAN></FONT></P>
<P><SPAN lang=en-us><FONT color=#800000><FONT face=Arial size=2>('146 -
Message', '02 - Primary Account Number is: 6751469991140620 ','10 - System Trace
Audit Number2:</FONT><B> <FONT face=Arial size=2>369315</FONT></B><FONT
face=Arial size=2>', 'FF47 - Security of the Internet:
')</FONT></FONT></SPAN></P>
<P><SPAN lang=en-us><FONT color=#800000><FONT face=Arial size=2>('146 -
Message', '02 - Primary Account Number is: 40593529008395201432 ','10 -
System Trace Audit Number2:</FONT><B> <FONT face=Arial
size=2>369385</FONT></B><FONT face=Arial size=2>', 'FF47 - Security of the
Internet: ')</FONT></FONT></SPAN></P>
<P><SPAN lang=en-us><FONT color=#800000><FONT face=Arial size=2>('146 -
Message', '02 - Primary Account Number is: 4059352900839520','10 - System Trace
Audit Number2:</FONT><B> <FONT face=Arial size=2>369365</FONT></B><FONT
face=Arial size=2>', 'FF47 - Security of the Internet:
')</FONT></FONT></SPAN></P>
<P><SPAN lang=en-us><FONT color=#800000><FONT face=Arial size=2>('146 -
Message', '02 - Primary Account Number is: 4059352900839520910','10 - System
Trace Audit Number2:</FONT><B> <FONT face=Arial size=2>369375</FONT></B><FONT
face=Arial size=2>', 'FF47 - Security of the Internet:
')</FONT></FONT></SPAN></P>
<P><SPAN lang=en-us><FONT face=Arial color=#800000 size=2>('844 Close Message',
'011 - System Trace Audit Number: 000012', '024 - Function Code: 860', '07 -
Year of the Purchase Transaction: 08')</FONT></SPAN></P><BR>
<P><SPAN lang=en-us><B><FONT face=Arial size=2>Output.txt
contents:</FONT></B></SPAN> <SPAN class=869260721-17092008><FONT face=Arial
color=#0000ff size=2> (<FONT color=#000000> which has fixed length format
of 142 bytes each line.</FONT>) </FONT></SPAN><BR><SPAN lang=en-us><FONT
face=Arial color=#800000 size=2>11
00000000000030004
050908024536000674000000
13
</FONT></SPAN></P>
<P><SPAN lang=en-us><FONT face=Arial color=#800000 size=2>23
0000000000003000400828000113105470509080245364247939
000000070824800000005090805008585147778978978050908050908
</FONT></SPAN></P>
<P><SPAN lang=en-us><FONT color=#800000><FONT face=Arial size=2>24
00000000000030004
050908024536424793900067514665529949730409080000000000000016
0000000000001600C</FONT><B><FONT face=Arial size=2>092222257UXT</FONT></B><FONT
face=Arial size=2> 050908</FONT></FONT></SPAN></P>
<P><SPAN lang=en-us><FONT color=#800000><FONT face=Arial size=2>24
00000000000030004
050908024536424793900051310150077578900409080000000000000018
0000000000001500C</FONT><B><FONT face=Arial size=2>092222259XUZ</FONT></B><FONT
face=Arial size=2> 050908</FONT></FONT></SPAN></P>
<P><SPAN lang=en-us><FONT color=#800000><FONT face=Arial size=2>24
00000000000030004
050908024536424793900067514665529949730409080000000000000016
0000000000001600C</FONT><B><FONT face=Arial size=2>092222257URT</FONT></B><FONT
face=Arial size=2> 050908</FONT></FONT></SPAN></P>
<P><SPAN lang=en-us><FONT color=#800000><FONT face=Arial size=2>24
00000000000030004
050908024536424793900051310150077578900409080000000000000018
0000000000001500C</FONT><B><FONT face=Arial size=2>092222304YUC</FONT></B><FONT
face=Arial size=2> 050908</FONT></FONT></SPAN></P>
<P><SPAN lang=en-us><FONT color=#800000><FONT face=Arial size=2>24
00000000000030004
050908024536424793900067514665529949730409080000000000000016
0000000000001600C</FONT><B><FONT face=Arial size=2>092222257OUE</FONT></B><FONT
face=Arial size=2> 050908</FONT></FONT></SPAN></P>
<P><SPAN lang=en-us><FONT face=Arial size=2><FONT color=#800000>55
00000000000030004
05090802453600067400000006
13</FONT>
</FONT></SPAN></P><BR><BR>
<P><SPAN lang=en-us><FONT face=Arial size=2>1. Parse the input file to get the
value (bold) appears next to string "System Trace Audit Number2".</FONT></SPAN>
<BR><SPAN lang=en-us><FONT face=Arial size=2>2. Replace the value (bold) with
database equivalent eg.</FONT><B> <FONT face=Arial
size=2>369325=092222257UXT</FONT></B></SPAN> <BR><SPAN lang=en-us><FONT
face=Arial size=2>3. Generate the output file as below where everything is
constant except bold text which is databse equivalent of parsed value from input
file.</FONT></SPAN></P>
<P><SPAN lang=en-us><FONT face=Arial size=2><SPAN
class=869260721-17092008>Appreciate your
help, </SPAN></FONT></SPAN><BR><SPAN lang=en-us><FONT face=Arial
size=2>Raj.</FONT></SPAN> </P><BR><BR></BODY></HTML>