nithinmurali / pygsheets

Google Sheets Python API v4
https://pygsheets.readthedocs.io/en/latest
Other
1.5k stars 220 forks source link

Make Worksheet.append_table() return the response #547

Closed ktpss95112 closed 2 years ago

ktpss95112 commented 2 years ago

Hi nithinmurali, thanks for maintaining this project! I opened issue #546 a few days ago. The issue is about returning the response of Worksheet.append_table() so that the user can obtain the index of the appended row. I made this PR to provide the feature. If it is inappropriate, please let me know. Thanks!

nithinmurali commented 2 years ago

Thanks for the PR!

As discussed in the linked issue:

we don't return the underlying raw json in any api calls. We always wrap the data in sensible data-structure and return them. In this case i would suggest that it should return GridRange appropriately.

The result should look something similar to this

{
    'tableRange': <GridRange Sheet1!A1:D4>,
    'updates': {
        'updatedRange': <GridRange Sheet1!A1:D4>,
        'updatedCells': 6,
        'updatedColumns': 3,
        'updatedRows': 2
    }
}
ktpss95112 commented 2 years ago

Thanks for your review. I updated the code and it should return something like this:

{   
    'tableRange': <GridRange result!A1:B12>, 
    'updates': {
        'updatedCells': 1,
        'updatedColumns': 1,
        'updatedRange': <GridRange result!A13:Z1009>,
        'updatedRows': 1
    }
}

Also, I found some spelling mistakes in worksheet.py and fixed them.