I have an issue where I'm uploading and trying to overwrite gsheet files to a dropbox app folder with the files.upload method. It runs successfully but I can't open the .gSheet file from my Dropbox folder. When I select 'Open in' > 'Google Sheets', I get taken to a screen stating ".gsheet files can't currently be previewed".
Code below:
def excel_overwrite_data_sheet(wb1Path,wb2Path😞
try:
output = io.BytesIO()
wb1 = openpyxl.load_workbook(io.BytesIO(dropbox_load_file('/Data/Book1.xlsx')))
ws1 = wb1.worksheets[0]
wb2 = openpyxl.load_workbook(io.BytesIO(dropbox_load_gsheet('/GSheetMetrics.gsheet')))
wb2.remove(wb2['Ticket Data'])
ws2 = wb2.create_sheet(ws1.title)
for row in ws1:
for cell in row:
ws2[cell.coordinate].value = cell.value
writer = pd.ExcelWriter(output, engine='openpyxl')
writer.book = wb2
writer.save()
output.seek(0)
dbx.files_upload(output.getvalue(),wb2Path,mode=dropbox.files.WriteMode.overwrite)
except Exception as e:
print('Error writing file to Dropbox: ' + str(e))