All

I have a string that has a bunch of numbers with the units attached to them.
I want to strip off the units.  I am using a regular expression and sub to
do this.  This works great for almost all of the cases.  

These are the type of lines:

SigWind:  857hPa,          ,  21.0C,  20.1C, 210 @  9kts
SigWind:  850hPa�,         ,       ,       , 205 @ 11kts
Std Lvl:  850hPa,     1503m,  16.8C,  15.7C, 205 @ 11kts

I am using the following cleanstring = re.compile( '(hPa|hPa\xb1|m|C|kts)'
).  And then the cleanstring.sub("",line).  I have tried using numerous \ to
escape the \xb1.

I also tried replacing all non numeric characters that are part of a
number-character string but I could not make that work. The idea was replace
all non-number characters in a "word" that is made up of numbers followed by
numbers.

I then split the line at the commas so in the current thinking I need the
commas for the split.  How do I deal with the hPa�?  When I print it out it
looks like it is a hexadecimal escape character (\xb1) but I am note sure
how to deal with this.

Any ideas?

Thanks
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to