[Tutor] Parse text with python
Mark Lawrence
breamoreboy at yahoo.co.uk
Thu Oct 17 22:23:05 CEST 2013
On 17/10/2013 20:54, Danilo Chilene wrote:
> Hello,
>
> I have the text below:
>
> CSMP0097I 14.42.12 CPU-B SS-BSS SSU-AA IS-02
>
> -LAL USER CONTROL FILE-
> MAXIMUM DEFINABLE USERS - 14999
> MAXIMUM CONFIGURABLE USERS - 11790
> CURRENT NUMBER USERS - 09692
> USER FLUSH CRET TIME VALUE - 5
> -LAL USER FILE-
> NAME UORD T/O O OXIT RXIT S MAX INUSE PCT
> ---------------- ---- --- - ---- ---- - --------- --------- ---
> J4IB 305 15 A 1700 6666 95
> KEYWORDS - TA/J4IB CRTSST DYNTAC HSSPDB
> DELTAS - OBTAIN 0 RELEASE 0 FLUSH VALUE 0
> DR CANDIDATE - N REPORT - N
> INUSE DATE - 10.17.2013
>
> END OF DISPLAY
>
>
> How I can grab the number 6666? My idea is to find the number 1700(this
> number never changes) and count 6 chars and the print the next 4 chars.
> But I didn't find *how to count chars and print next* on python.
>
> Any ideas?
>
> Best Regards,
>
> Danilo F. Chilene
>
Use the string find method described here
http://docs.python.org/3/library/stdtypes.html#string-methods to get an
offset for 1700. Add 6 to it. Print a slice of 4 characters starting
from this offset. If you don't know what slicing is please read the
appropriate section here
http://docs.python.org/3/tutorial/introduction.html#strings.
--
Roses are red,
Violets are blue,
Most poems rhyme,
But this one doesn't.
Mark Lawrence
More information about the Tutor
mailing list