LoginSignup
1
2

More than 3 years have passed since last update.

Quip APIを作成してみた

Posted at

はじめに

Quip上のスプレットシートに保存されたテキストを解析するために、Quip APIでQuipの特定のドキュメントにアクセスした。その際のアクセス方法を個人用にメモしておく。
※個人メモなので省略しまくってます。

Access Tokenの取得

POSTMANでTokenを取得する。
詳しくは、Quip API Documentationを参照


GET https://platform.quip.com/1/users/current

実際にアクセスする

Github上のスプレットシートを取得する関数を用いてフォルダとドキュメントを取得する。

quip_analysis.py

import quip

# access to the quip
client = quip.QuipClient(access_token=<access_token>)

# Get your thread_id from the URL of your document
user = client.get_authenticated_user()
starred = client.get_folder(user["starred_folder_id"])

# get the spreadsheet
spreadsheet = client.get_second_spreadsheet(thread_id=<thread_id>)
parsedSpreadsheet = client.parse_spreadsheet_contents(spreadsheet)

スプレット形式のデータを取得できるのでデータフレームに落とし込む

quip_analysis.py
# create the dataframe
    counter = 0
    spreadsheetData = []
    colNames = []

    for rows in parsedSpreadsheet["rows"]:
        cells = rows["cells"]
        rowData = []
        for key, value in cells.items():
            if counter == 0:
                colNames.append(key)
            rowData.append(value['content'])
        spreadsheetData.append(rowData)
        counter += 1   
    l = pd.DataFrame(spreadsheetData, columns=colNames)

このあと形態素解析でドキュメント上の頻出ワードを抽出した。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2