Mar-06-2018, 02:12 PM
I tested using the test_data()
As you know that works fine, but when I use db_query() instead it throws an error
ValueError: could not convert string to float
I went through the debugging (step through) and in the def parse_row(row)
key: 'g'
code: 'e'
at geo_data = [parse_row(row[1]) for row in cur]
row: <class 'tuple'>: ('9fde ... 246b', 'geo12.08 ... 45.50 ... 0.000000test')
So it looks like something is going wrong in the following, for some reason the key (row[0])is being ignored and the row[1] is behaving strangely, perhaps tuples behave differently? I've spent today looking into this, but I'm struggling to find the solution, strange that it works for the test_data() but not the database data. Should I add I'm using Python 3?
As you know that works fine, but when I use db_query() instead it throws an error
ValueError: could not convert string to float
I went through the debugging (step through) and in the def parse_row(row)
key: 'g'
code: 'e'
at geo_data = [parse_row(row[1]) for row in cur]
row: <class 'tuple'>: ('9fde ... 246b', 'geo12.08 ... 45.50 ... 0.000000test')
So it looks like something is going wrong in the following, for some reason the key (row[0])is being ignored and the row[1] is behaving strangely, perhaps tuples behave differently? I've spent today looking into this, but I'm struggling to find the solution, strange that it works for the test_data() but not the database data. Should I add I'm using Python 3?
def parse_row(row): # extract lat, lon # you may need to round the float number to # correct number of decimal digits key = row[0] code=row[1][:3] lat = float(row[1][3:15]) lon = float(row[1][15:27]) elevation = float(row[1][27:39]) descr = row[1][39:] return geojson.Feature(geometry=geojson.Point((lon, lat, elevation)), id=key, properties={'code':code, 'elevation':elevation, 'description':descr})