On Wed, Sep 17, 2008 at 5:08 PM, Kamisetty, Rajendra <[EMAIL PROTECTED]> wrote: > 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: > ('146 - Message', '02 - Primary Account Number is: 6751469991140620','10 - > System Trace Audit Number2: 369325', 'FF47 - Security of the Internet: ')
> 1. Parse the input file to get the value (bold) appears next to string > "System Trace Audit Number2". If that is really all you need then a regular expression search could do it. If you need more data from the input then some sort of parser might be the easiest solution, perhaps using pyparsing. http://pyparsing.wikispaces.com/ > 2. Replace the value (bold) with database equivalent eg. 369325=092222257UXT The DB-API specification tells generally how to interface to a database. Some specifics depend on the particular database. http://www.python.org/dev/peps/pep-0249/ > 3. Generate the output file as below where everything is constant except > bold text which is databse equivalent of parsed value from input file. The output doesn't look very constant to me. If you can show what you have tried and tell us where you are stuck we can better help you. Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor