I'm making a bot that accesses data from a google sheet and tweets data in a particular cell. Previously I was running this from a local csv file using csv module but decided to make it on sheets so I don't need to push to heroku every time I add more data.
while True:
try:
while True:
sheet = client.open("Lyrics").sheet1
rand = random.randint(1,int(sheet.cell(1,11).value))
d = sheet.cell(1+rand,1).value
#api.update_status(status = d)
print(rand)
print(sheet.cell(1+rand,1).value)
time.sleep(10)
except:
print("Error")
time.sleep(10)
I tried the original code (not posted here) first but I got a lot of errors so I started dissecting everything to see where error could be. Some of the code (print(sheet.cell(1+rand,1).value)
) seems redundant but I couldn't get it to print d
because of some TypeError. I stopped the tweeting part to see if somehow that was causing it but it doesn't seem to be from twitter. This code works as expected
while True:
try:
while True:
sheet = client.open("Lyrics").sheet1
rand = random.randint(1,int(sheet.cell(1,11).value))
d = sheet.cell(1+rand,1).value
api.update_status(status = d)
print(rand)
#print(sheet.cell(1+rand,1).value)
time.sleep(10)
except:
print("Error")
#time.sleep(10)
so I'm guessing it has something to do with calling sheets?
I don't absolutely need to see the data because I'm not going to see the console anyway but I would like to know and understand why this is happening.
Aucun commentaire:
Enregistrer un commentaire