Skip to content

Commit

Permalink
Add get charts function (#542)
Browse files Browse the repository at this point in the history
* Add get charts function

* code refactoring

* solve linting

* Add cookbook
  • Loading branch information
ravi03071991 authored Dec 9, 2024
1 parent 3651a10 commit 4740d06
Show file tree
Hide file tree
Showing 5 changed files with 700 additions and 480 deletions.
252 changes: 252 additions & 0 deletions examples/demo_get_charts.ipynb

Large diffs are not rendered by default.

59 changes: 29 additions & 30 deletions examples/demo_json_tour.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "0879301c-ff91-4431-941a-6c0ef7cd8fe2",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -65,7 +65,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "c39d408f-e885-4940-85c7-b09ca3bc7cb7",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -112,7 +112,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "9c9cd670-8229-4ad6-99a9-845bd82b7ec1",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -141,7 +141,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "c588c578",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -169,7 +169,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "f8845fac",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -206,7 +206,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "6eca0253",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -234,7 +234,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "c0354ba7",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -287,7 +287,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "d236a255",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -318,7 +318,7 @@
}
],
"source": [
"print(pages[0]['text'])"
"print(pages[0][\"text\"])"
]
},
{
Expand All @@ -339,7 +339,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"id": "63d2df6f",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -375,7 +375,7 @@
}
],
"source": [
"print(pages[0]['md'])"
"print(pages[0][\"md\"])"
]
},
{
Expand Down Expand Up @@ -429,7 +429,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": null,
"id": "0975cbc4",
"metadata": {},
"outputs": [
Expand All @@ -450,8 +450,8 @@
}
],
"source": [
"image_data = pages[0]['images'][0].copy()\n",
"del image_data['ocr']\n",
"image_data = pages[0][\"images\"][0].copy()\n",
"del image_data[\"ocr\"]\n",
"print(json.dumps(image_data, indent=2))"
]
},
Expand All @@ -465,7 +465,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": null,
"id": "908e1cfd",
"metadata": {},
"outputs": [
Expand All @@ -482,12 +482,12 @@
"source": [
"# Make a copy of json_objs with only the first page to avoid downloading all the images\n",
"first_page_json = json_objs.copy()\n",
"first_page_json[0]['pages'] = [first_page_json[0]['pages'][0]] # Keep only first page\n",
"first_page_json[0][\"pages\"] = [first_page_json[0][\"pages\"][0]] # Keep only first page\n",
"\n",
"# get the SDK to download all the images to a local directory for us\n",
"images = parser.get_images(first_page_json, download_path=\"./json_tour_screenshots\")\n",
"\n",
"print(images[0]['path'])"
"print(images[0][\"path\"])"
]
},
{
Expand All @@ -508,7 +508,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": null,
"id": "b8daf90d",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -618,7 +618,7 @@
}
],
"source": [
"print(json.dumps(pages[0]['images'][0]['ocr'],indent=2))"
"print(json.dumps(pages[0][\"images\"][0][\"ocr\"], indent=2))"
]
},
{
Expand All @@ -641,7 +641,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": null,
"id": "c10b9d7d",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -782,7 +782,7 @@
}
],
"source": [
"print(json.dumps(pages[0]['items'],indent=2))"
"print(json.dumps(pages[0][\"items\"], indent=2))"
]
},
{
Expand All @@ -807,7 +807,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": null,
"id": "7d6404a5",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -857,7 +857,7 @@
}
],
"source": [
"print(json.dumps(pages[34]['items'][2],indent=2))"
"print(json.dumps(pages[34][\"items\"][2], indent=2))"
]
},
{
Expand All @@ -872,7 +872,7 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": null,
"id": "fb0da11a",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -909,7 +909,7 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": null,
"id": "e7e393e6",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -945,7 +945,7 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": null,
"id": "29bf7e3c",
"metadata": {},
"outputs": [
Expand All @@ -967,8 +967,8 @@
}
],
"source": [
"link_page = link_parsed[0]['pages'][0]\n",
"print(json.dumps(link_page['links'],indent=2))"
"link_page = link_parsed[0][\"pages\"][0]\n",
"print(json.dumps(link_page[\"links\"], indent=2))"
]
},
{
Expand All @@ -995,8 +995,7 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 4740d06

Please sign in to comment.