Thursday, 29 November 2018

Google sheets APIv4 comment data to pandas df, not values

I'm getting the notes for ranges A1:E7 of a sheet. There are notes in B1, E1, D4 and B7.

result = gsheets.service.spreadsheets().get(spreadsheetId=key, fields="sheets/data/rowData/values/note").execute()
data=result['sheets'][0]['data'][0]

produces the following dictionary:

{u'rowData': [
        {u'values': [{}, {u'note': u'B1 notes'}, {}, {}, {u'note': u'E1 notes'}]},
        {}, 
        {}, 
        {u'values': [{}, {}, {}, {u'note': u'D4 notes'}]},
        {}, 
        {}, 
        {u'values': [{}, {u'note': u'B7 notes'}]}
        ]
}

Now how do I get this into a 7x5 dataframe that mimics the range A1:E7? I want to use '' for the blank cells.



from Google sheets APIv4 comment data to pandas df, not values

No comments:

Post a Comment