1

Trying to export a file from gsheet using python and I encountered this issue, may I know what I need to add on my script?

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "exportSizeLimitExceeded",
    "message": "This file is too large to be exported."
   }
  ],
  "code": 403,
  "message": "This file is too large to be exported."
 }
}

Heres my script when I got the error

path = "/root/xlsx/"
prefix = "Remastered"
suffix = datetime.datetime.now().strftime("%Y%m%d")
filename = prefix + "_" + suffix + ".xlsx"
v = os.path.join(path, filename)
print(v)
 
with open(v, 'wb') as f:
  f.write(res.content)
rodskies
  • 119
  • 1
  • 11
  • 1
    In this case, in order to correctly replicate your situation, can you provide the sample Spreadsheet for replicating your issue? By this, I would like to confirm it. Or, although I cannot test this, in your situation, for example, when the URL is changed to `https://docs.google.com/spreadsheets/export?exportFormat=xlsx&id=###YourSpreadsheetId###`, will your issue be removed? – Tanaike Nov 18 '21 at 01:58
  • May I know if there is a way that we can modify the script that can able to export a spreadsheet with no limitation? – rodskies Nov 18 '21 at 02:09
  • I change the url using this code but the issue change from "exportsizelimitexceeded" to Not found. May I know if I was correct on my modification? >>>>> url = "https://www.googleapis.com/drive/v3/files/" + "https://docs.google.com/spreadsheets/export?exportFormat=xlsx&id=SpreadsheetID" – rodskies Nov 18 '21 at 02:23
  • Hi I figured it out what I need to change :D the first solution above my first comment is working. Thank you again! great @Tanake – rodskies Nov 18 '21 at 02:38
  • Thank you for replying. From your replying, I could understand that when the URL is modified to `https://docs.google.com/spreadsheets/export?exportFormat=xlsx&id=###YourSpreadsheetId###`, your issue was resolved. I'm glad for it. I thought that this might be useful for other users. So I posted it as an answer. Could you please confirm it? – Tanaike Nov 18 '21 at 03:17

1 Answers1

0

Please modify url and test it again.

From:

url = "https://www.googleapis.com/drive/v3/files/" + "sdfasdasdasdasdadsa_1231_123" + "/export?mimeType=application%2Fvnd.openxmlformats-officedocument.spreadsheetml.sheet"

To:

url = "https://docs.google.com/spreadsheets/export?exportFormat=xlsx&id=###YourSpreadsheetId###"
Tanaike
  • 181,128
  • 11
  • 97
  • 165