Hi, I am new to Python and need your help to generate an output file as explained below.
I need to generate an output text file based on the input text file data . Input.txt contents: ('844 - Open File Message', '011 - System Trace Audit Number: 823301', '012 - Local Time: 033543', '013 - Local Date: 0821', '024 - Function Code: 861') ('844 - Open Service Message', '011 - System Trace Audit Number: 000003', '012 - Local Time: 033543', '013 - Local Date: 0821', '024 - Function Code: 865') ('345 - Remittance Open Message', '011 - System Trace Audit Number: 023301', '026 - Upload Control: 000001') ('146 - Message', '02 - Primary Account Number is: 6751469991140620','10 - System Trace Audit Number2: 369325', 'FF47 - Security of the Internet: ') ('146 - Message', '02 - Primary Account Number is: 6751469991140620 ','10 - System Trace Audit Number2: 369315', 'FF47 - Security of the Internet: ') ('146 - Message', '02 - Primary Account Number is: 40593529008395201432 ','10 - System Trace Audit Number2: 369385', 'FF47 - Security of the Internet: ') ('146 - Message', '02 - Primary Account Number is: 4059352900839520','10 - System Trace Audit Number2: 369365', 'FF47 - Security of the Internet: ') ('146 - Message', '02 - Primary Account Number is: 4059352900839520910','10 - System Trace Audit Number2: 369375', 'FF47 - Security of the Internet: ') ('844 Close Message', '011 - System Trace Audit Number: 000012', '024 - Function Code: 860', '07 - Year of the Purchase Transaction: 08') Output.txt contents: ( which has fixed length format of 142 bytes each line.) 11 00000000000030004 050908024536000674000000 13 23 0000000000003000400828000113105470509080245364247939 000000070824800000005090805008585147778978978050908050908 24 00000000000030004 050908024536424793900067514665529949730409080000000000000016 0000000000001600C092222257UXT 050908 24 00000000000030004 050908024536424793900051310150077578900409080000000000000018 0000000000001500C092222259XUZ 050908 24 00000000000030004 050908024536424793900067514665529949730409080000000000000016 0000000000001600C092222257URT 050908 24 00000000000030004 050908024536424793900051310150077578900409080000000000000018 0000000000001500C092222304YUC 050908 24 00000000000030004 050908024536424793900067514665529949730409080000000000000016 0000000000001600C092222257OUE 050908 55 00000000000030004 05090802453600067400000006 13 1. Parse the input file to get the value (bold) appears next to string "System Trace Audit Number2". 2. Replace the value (bold) with database equivalent eg. 369325=092222257UXT 3. Generate the output file as below where everything is constant except bold text which is databse equivalent of parsed value from input file. Appreciate your help, Raj.
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor