0

(Beginner) I am attempting to copy and paste specific values from one google sheet to another. In another question that I asked, a user suggested this code:

   spreadsheetId = "###"  # Please set the Spreadsheet ID.
sourceSheetName = "Sheet1"  # Please set the sheet name of source sheet.
destinationSheetName = "Sheet2"  # Please set the sheet name of destination sheet.

client = gspread.authorize(credentials)
spreadsheet = client.open_by_key(spreadsheetId)
sourceSheetId = spreadsheet.worksheet(sourceSheetName)._properties['sheetId']
destinationSheetId = spreadsheet.worksheet(destinationSheetName)._properties['sheetId']
body = {
    "requests": [
        {
            "copyPaste": {
                "source": {
                    "sheetId": sourceSheetId,
                    "startRowIndex": 0,
                    "endRowIndex": 5,
                    "startColumnIndex": 0,
                    "endColumnIndex": 5
                },
                "destination": {
                    "sheetId": destinationSheetId,
                    "startRowIndex": 0,
                    "endRowIndex": 5,
                    "startColumnIndex": 0,
                    "endColumnIndex": 5
                },
                "pasteType": "PASTE_VALUES"
            }
        }
    ]
}
res = spreadsheet.batch_update(body)
print(res)

However, I receive a syntax error at "pasteType": "PASTE_VALUES" Why is this happening and how can I fix it?

Jordan
  • 63
  • 2
  • 8
  • Can I ask you that why you don't ask this at [the question](https://stackoverflow.com/questions/60764039/how-do-you-copy-values-from-one-spreadsheet-to-another-using-gspread-or-some-oth)? – Tanaike Mar 21 '20 at 23:22
  • I read that the most effective thing to do was to ask another question. By the way, thank you for the response on the other post! – Jordan Mar 22 '20 at 00:31
  • Thank you for replying. In this case, I recommend to ask this to [the answer](https://stackoverflow.com/a/60783905/7108653) as a comment. Because your this question is related to the answer. But if you have other question without being related to the answers in your previous question, I recommend to post it as new question. – Tanaike Mar 22 '20 at 00:43
  • I realized I was missing a comma after the } in the previous line – Jordan Mar 22 '20 at 01:01

1 Answers1

0

Missing a comma in the previous line

Jordan
  • 63
  • 2
  • 8