0

Because QGIS opens MS Excell tables with string type only, in processing plugin I need to use any field types.

def deg2dms(degree):
    deg = degree
    d = int(deg)
    m = int((deg - d) * 60)
    s = float(((deg - d) * 60 - m) * 60)
    return "{}°{}'{}''".format(d, m, round(s, 2))

But code executes with error:

d = int(deg) TypeError: int() argument must be a string, a bytes-like object or a number, not 'QVariant'

How to convert type QVariant to float?

1 Answer 1

1

You can use the QVariant.value() method. Applied to your script, it would be something like deg.value().

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.