0

I am using the below code to send df to a google sheet. Data is being exported to sheet1 within google sheets. Is there a way how I can modify my code to send another dataframe to sheet2 within the same google worksheet?

gc = pygsheets.authorize(service_file)
df = df.values.tolist()
sh = gc.open_by_url(sheet_url)
wks = sh[0]
wks.update_cells(crange='A2',values = df)

I tried copying sheet2 url but when I run my code data is still being exported to sheet1.

Mtra
  • 201
  • 4
  • 10

1 Answers1

0

Something like this probably;

sh_2 = gc.open_by_url(sheet_url_2)
wks_2 = sh_2[0]
wks_2.update_cells(crange='A2',values = df_2)
Zanshin
  • 1,262
  • 1
  • 14
  • 30
  • already tried this but content is still being uploaded to sheet1. Just to be clear I have 2 tabs called sheet1 and sheet2 in the same Google Sheet. – Mtra Nov 22 '18 at 14:20