-1

I am fetching daily order book and profit/loss data using broker API and feeding them using python with the help of Gspread library. Following code, I am using to feed fetched order book data from broker into google sheet.

wkob.update('A2',[obdf.columns.values.tolist()] + obdf.values.tolist())

I have to run this python daily using Windows Schduler but each time I am running python file data has been over written on existing one in Googlesheet. I used following code to fetech existing value of available data on sheet but dont know how to use this value to add fresh data next row of existing one. Please help regarding this.

len(wkpnl.get_all_values())

Auto update fresh value after previously updated data in google sheet using python. Screenshot of code

Tanaike
  • 181,128
  • 11
  • 97
  • 165

1 Answers1

0

In your script, how about the following modification?

From:

wkob.update('A2',[obdf.columns.values.tolist()] + obdf.values.tolist())

To:

wkob.append_rows([obdf.columns.values.tolist()] + obdf.values.tolist(), value_input_option="USER_ENTERED")
  • By this modification, the values are appended to the sheet.

  • If you want to put only the values, how about the following modification?

      wkob.append_rows(obdf.values.tolist(), value_input_option="USER_ENTERED")
    

Reference:

Tanaike
  • 181,128
  • 11
  • 97
  • 165
  • @Sandeep Yadav Did my answer show you the result what you want? Would you please tell me about it? That is also useful for me to study. If this works, other people who have the same issue with you can also base your question as a question which can be solved. If you have issues for my answer yet, I apologize. At that time, can I ask you about your current situation? I would like to study to solve your issues. – Tanaike Dec 23 '22 at 01:06