Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   how to build Object for List data (http://www.velocityreviews.com/forums/t953166-how-to-build-object-for-list-data.html)

moonhkt 10-08-2012 04:10 PM

how to build Object for List data
 
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

Laszlo Nagy 10-08-2012 06:50 PM

Re: how to build Object for List data
 
>
> 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?

Joel Goldstick 10-08-2012 07:13 PM

Re: how to build Object for List data
 
On Mon, Oct 8, 2012 at 2:50 PM, Laszlo Nagy <gandalf@shopzeus.com> 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


All times are GMT. The time now is 08:05 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.