how to build Object for List data

Discussion in 'Python' started by moonhkt, Oct 8, 2012.

  1. moonhkt

    moonhkt Guest

    Hi All

    I have Data call FM01. Each format have F1.. F50 Fields. And Global
    Program G1..Gn.

    The format like below as text file

    FM01

    Fld # Field Validation
    1 F1 N/A
    2 F2 N/A
    3 F3 Program1,1,2,3 # Add F1 and F2 value to F3
    4 F4 Program2,1,3,4 # Add F1 and F3 value to F4
    ....
    50


    Seq validation
    1 Program3,1,3,4 # max(F1,F3) to F4
    .......
    n
    How to using python to Read the text file, Build the data as object
    class ?

    moonhkt
    moonhkt, Oct 8, 2012
    #1
    1. Advertising

  2. moonhkt

    Laszlo Nagy Guest

    >
    > Seq validation
    > 1 Program3,1,3,4 # max(F1,F3) to F4
    > ......
    > n
    > How to using python to Read the text file, Build the data as object
    > class ?

    Open the file using the open() command. Then iterate over the lines
    within a stateful algorithm that parses the lines with regular expressions.

    What did you try so far?
    Laszlo Nagy, Oct 8, 2012
    #2
    1. Advertising

  3. On Mon, Oct 8, 2012 at 2:50 PM, Laszlo Nagy <> wrote:
    >>
    >> Seq validation
    >> 1 Program3,1,3,4 # max(F1,F3) to F4
    >> ......
    >> n
    >> How to using python to Read the text file, Build the data as object
    >> class ?

    >
    > Open the file using the open() command. Then iterate over the lines within a
    > stateful algorithm that parses the lines with regular expressions.


    before you go the regex route try str.split() since it looks like your
    columns are separated by tabs or spaces. You could also look into csv
    package.

    >
    > What did you try so far?
    > --
    > http://mail.python.org/mailman/listinfo/python-list




    --
    Joel Goldstick
    Joel Goldstick, Oct 8, 2012
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vagif Abilov
    Replies:
    2
    Views:
    547
    Vagif Abilov
    Jul 7, 2004
  2. Dmitry Ponyatov
    Replies:
    1
    Views:
    462
    James Mills
    Apr 21, 2010
  3. Nico Grubert
    Replies:
    0
    Views:
    286
    Nico Grubert
    Jun 30, 2010
  4. Stefan Behnel
    Replies:
    0
    Views:
    491
    Stefan Behnel
    Jun 30, 2010
  5. Replies:
    0
    Views:
    113
Loading...

Share This Page