how to build Object for List data

M

moonhkt

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
 
L

Laszlo Nagy

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?
 
J

Joel Goldstick

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top