Querying the Datastore in python
- by Ray
Greetings!
I am trying to work with a single column in the datatstore, I can view and display the contents, like this -
q = test.all()
q.filter("adjclose =", "adjclose")
q = db.GqlQuery("SELECT * FROM test")
results = q.fetch(5)
for p in results:
p1 = p.adjclose
print "The value is --> %f" % (p.adjclose)
however i need to calculate the historical values with the adjclose column, and I am not able to get over the errors
for c in range(len(p1)-1):
TypeError: object of type 'float' has no len()
here is my code!
for c in range(len(p1)-1):
p1.append(p1[c+1]-p1[c]/p1[c])
p2 = (p1[c+1]-p1[c]/p1[c])
print "the p1 value<-- %f" % (p2)
print "dfd %f" %(p1)
new to python, any help will be greatly appreciated!
thanks in advance
Ray
HERE IS THE COMPLETE CODE
class CalHandler(webapp.RequestHandler):
def get(self):
que = db.GqlQuery("SELECT * from test")
user_list = que.fetch(limit=100)
doRender(
self,
'memberscreen2.htm',
{'user_list': user_list} )
q = test.all()
q.filter("adjclose =", "adjclose")
q = db.GqlQuery("SELECT * FROM test")
results = q.fetch(5)
for p in results:
p1 = p.adjclose
print "The value is --> %f" % (p.adjclose)
for c in range(len(p1)-1):
p1.append(p1[c+1]-p1[c]/p1[c])
print "the p1 value<--> %f" % (p2)
print "dfd %f" %(p1)