Updating a Gsheet with Gspread and pandas

Asked

Viewed 19 times

-3

I am getting a bit to use python and am trying to update a google sheet through gspread and reading a CSV that is on my pc with pandas.

my code stayed:

import gspread
from oauth2client.service_account import ServiceAccountCredentials
import pandas as pd

from pprint import pprint
scope = ["https://www.googleapis.com/auth/spreadsheets", "https://www.googleapis.com/auth/drive",
          "https://www.googleapis.com/auth/drive.file", "https://spreadsheets.google.com/feeds"]

creds = ServiceAccountCredentials.from_json_keyfile_name("credentials.json",scope)

client = gspread.authorize(creds)

sheet = client.open_by_url("https://docs.google.com/spreadsheets/d/1FL..._5rQcs/edit#gid=0").sheet1

tabela = pd.read_csv(r"C:\Users\washington\Downloads\SLA de devolução [EX001].csv")

sheet.update([tabela()])

Debugging, it rotates well to the last line: sheet.update([tabela()])

It presents the following error:

  Traceback (most recent call last):
  File "C:/Users/washington/Desktop/ProjetosPy/LogGoogle/sheets.py", line 19, in <module>
    sheet.update([tabela()])
TypeError: 'DataFrame' object is not callable

Does anyone have any tips on how to fix this mistake?

  • The variable tabela is not a function, but a dataframe. Instead of sheet.update([tabela()]), try to use sheet.update([tabela]).

  • Showw! Gave good!! thank you very much!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.