[Tutor] Parse text with python

David Rock david at graniteweb.com
Thu Oct 17 23:30:55 CEST 2013


* Danilo Chilene <bicofino at gmail.com> [2013-10-17 17:55]:
> Hi,
> 
> The part that always change is the 6666, it can be 1 digit or 4 digits.
> Example: 1.
> The part that never changes is the 1700.

I think the point is we have a hard time believing that 1700 will never
change.  What do you plan to do when it does down the line?  It's
generally a bad idea to focus on something that is obviously a data
field as an item to key off of.

That said, another approach you could take is to use split().  Split
each line, check to see if 1700 is in it, then just grab the next field.
Inherent dangers:
INUSE field may be empty, so you will grab the wrong value
1700 might be somewhere other than where you expect it
etc


-- 
David Rock
david at graniteweb.com


More information about the Tutor mailing list