Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Notion to Pandas
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Notion_to_Pandas.ipynb",
"version": "0.3.2",
"provenance": [],
"collapsed_sections": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "code",
"metadata": {
"id": "UIUDmd5p34OZ",
"colab_type": "code",
"colab": {}
},
"source": [
"%pip install notion"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "Md13fa5R36xM",
"colab_type": "code",
"colab": {}
},
"source": [
"from getpass import getpass\n",
"\n",
"print('Go to Notion.so, open developer tools, go to Application tab, Cookies, and copy the value of token_v2')\n",
"token = getpass()"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "hSw9gd-Q4Z6V",
"colab_type": "code",
"colab": {}
},
"source": [
"from notion.client import NotionClient\n",
"\n",
"notion = NotionClient(token_v2=token)\n",
"\n",
"# This is a link of a table\n",
"rows = notion.get_block(block_url).collection.get_rows()\n",
"\n",
"table_data = [row.get_all_properties() for row in rows]"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "fL9ySGoV46Ah",
"colab_type": "code",
"colab": {}
},
"source": [
"import pandas as pd\n",
"\n",
"pd.DataFrame(table_data)"
],
"execution_count": 0,
"outputs": []
}
]
}
@josegarciav

This comment has been minimized.

Copy link

@josegarciav josegarciav commented Nov 2, 2020

THANK YOU

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment