0

I wrote a script that takes an excel file and transforms it into a data frame then upload its value to a google sheet. my problem is that I change the row range manually and I want it to append to the next row automatically

    CLIENT_SECRET_FILE = r'path'
    API_SERVICE_NAME = 'sheets'
    API_VERSION = 'v4'
    SCOPES = ['https://www.googleapis.com/auth/spreadsheets']
    gsheetId = 'id'
    
    service = Create_Service(CLIENT_SECRET_FILE, API_SERVICE_NAME, API_VERSION, SCOPES)
    
    def Export_Data_To_Sheets():
        
        URL = r'path'
        df = pd.read_excel(URL)
        df.replace(np.nan, '', inplace=True)
    
        response_date = service.spreadsheets().values().append(
            spreadsheetId=gsheetId,
            valueInputOption='RAW',
            range='Raw-Data!A25:N25', //here is what I want to fix
            body=dict(
                majorDimension='ROWS',
                values=df.T.reset_index().T.values.tolist())
        ).execute()


Export_Data_To_Sheets()

1 Answer 1

1

In this case, please remove !A25:N25 from range='Raw-Data!A25:N25' as follows.

Modified script:

From:
range='Raw-Data!A25:N25',
To:
range='Raw-Data',
  • By this modification, values is appended to the sheet of Raw-Data.

Reference:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.