Python Forum
Jump to next empty column with Google Sheets & Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Jump to next empty column with Google Sheets & Python
#1
I have a series of python scripts that enter data into a Google sheets column. I want to jump over to the next empty column if I run everything the next day. Here's a simple version of what I've got - it just puts today's date into cell A1.

import gspread
from oauth2client.service_account import ServiceAccountCredentials

scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']
creds = ServiceAccountCredentials.from_json_keyfile_name('client_penny.json', scope)
client = gspread.authorize(creds)

from datetime import datetime

date = datetime.today().strftime('%Y-%m-%d')

penny = client.open('pennystocks').worksheet('DGTW')

penny.update_acell('A1', date)
I want the date to go into B1 if I run it tomorrow (or whatever the next available column is if I've already run it a few times).

I found these related examples, but I think they're for javascript. (I'm a noon at this)

https://webapps.stackexchange.com/questi...ati/101200

https://webapps.stackexchange.com/questi...fic-column
Reply
#2
Hey there, I am currently having the same question, I need to update a google sheet every hour with 2 new columns of data but I need it to jump to next empty column to begin wrtitng the data.

Did you find a solution to this could you share it with me in case you have one?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Google Sheets API Error Connerb42 3 1,405 Mar-13-2021, 09:25 AM
Last Post: dalebreton
  How to fix and extract Google CSE JSON API using Python.exe venkatsrrecruiter 1 1,029 May-04-2019, 07:33 PM
Last Post: venkatsrrecruiter
  Interfacing Google Chrome & Python akornrumpf 5 1,695 Mar-16-2019, 10:20 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020