Question

I found the following example from another question: Here

It has some pyparsing code like this:

from pyparsing import *

survey = '''GPS,PN1,LA52.125133215643,LN21.031048525561,EL116.898812'''

number = Word(nums+'.').setParseAction(lambda t: float(t[0]))
separator = Suppress(',')
latitude = Suppress('LA') + number
longitude = Suppress('LN') + number
elevation = Suppress('EL') + number

line = (Suppress('GPS,PN1,')
        + latitude
        + separator
        + longitude
        + separator
        + elevation)

print line.parseString(survey)

It says that the output is:

[52.125133215643, 21.031048525561, 116.898812]

However, I get the following output:

[W:(0123...), W:(0123...), W:(0123...)]

How can I get float outputs instead of these "W:(0123...)" values?

Thanks!

Était-ce utile?

La solution

I upgraded my python and pyparsing version and it still did not work correctly. However, the next morning it suddenly worked just fine. I'm not sure why, maybe the restart overnight did something. Either way, it appears to work correctly now.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top