Automatically insert a python data frame in quip

917 views Asked by At

I have a data frame:

data drama df

I want to automatically insert the data frame details in quip. I have searched online, but couldn't find any satisfactory answer. Please help

1

There are 1 answers

0
Preston Frasch On

here is my answer based on a similar problem and this article: https://towardsdatascience.com/updating-a-quip-spreadsheet-with-python-api-1b4bb24d4aac

First, follow the step to get and use a personal access token from quip.com/dev/token--this will help with your authentication.

Then, you can get an updated client version from Lynn Zheng's medium post (linked above) https://github.com/RuolinZheng08/quip-api for local import.

My imports look like this:

import quip_update as quip #from Zheng's repo
from login_token import login_token #this is a variable that holds the value of the token I got from their auth website

Then you setup/authorize the client with the following:

quip_client = quip.QuipClient(access_token=login_token, base_url='https://platform.quip.com')

user = quip_client.get_authenticated_user()

If your company has a contract with quip, it might look like base_url='https://platform.quip-amazon.com'

I like to print(user) to see basic info/that the client connected.

Then, again mostly narrating Zheng's article, you can use one of the client functions to insert a spreadsheet:

def add_to_spreadsheet(self, thread_id, *rows, **kwargs):
'''Adds the given rows to the named (or first) spreadsheet in the
        given document.

            client = quip.QuipClient(...)
            client.add_to_spreadsheet(thread_id, ["5/1/2014", 2.24])'''
    
    

from quip.py

So you can put a spreadsheet in manually and then call to it by name="name of spreadsheet" to incorporate rows from Pandas.

So, for example: sample commands to update spreadsheet in document