How to write a python script to manipulate google spreadsheet data

GeminiDNK picture GeminiDNK · Mar 4, 2010 · Viewed 14k times · Source

I am able to get the feed from the spreadsheet and worksheet ID. I want to capture the data from each cell.

i.e, I am able to get the feed from the worksheet. Now I need to get data(string type?) from each of the cells to make a comparison and for input.

How exactly can I do that?

Answer

Warwick picture Warwick · Dec 12, 2011

There's another spreadsheet library worth to look at: gspread. I've used Google's data libary mentioned above and to me the provided api is weird. You need to extract spreadsheet's key to start working with this spreadsheet.

Here it's a way simpler. If you need to fetch the data from a cell you can just open a worksheet and get the value:

g = gspread.login('[email protected]', 'password')

worksheet = g.open('name_of_the_spreadsheet').get_worksheet(0)

# Say, you need A2
val = worksheet.cell(2, 1).value

# And then update
worksheet.update_cell(2, 1, '42')