-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create notebook to upload test data to dataland
- Loading branch information
1 parent
122de23
commit 06e633b
Showing
1 changed file
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"document_id='4abdfd0764559831fdd2e972abab0f34bc7300c650f6f789beea10ecb7d20251'\n", | ||
"[CompanyIdAndName(company_name='E.ON SE', company_id='8863987f-df05-452f-8067-11f72e771345')]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"%run base.ipynb\n", | ||
"import json\n", | ||
"from pathlib import Path\n", | ||
"\n", | ||
"from dataland_qa_lab.utils import config\n", | ||
"\n", | ||
"pdf_path = Path(\"../data/pdfs/\")\n", | ||
"json_path = Path(\"../data/jsons/\")\n", | ||
"\n", | ||
"conf = config.get_config()\n", | ||
"dataland_client = conf.dataland_client\n", | ||
"\n", | ||
"dataset = dataland_client.company_api.get_companies_by_search_string(search_string=\"E.ON SE\", result_limit=1)\n", | ||
"\n", | ||
"# upload pdf file to dataland\n", | ||
"if not dataland_client.documents_api.get_document(\n", | ||
" document_id=\"4abdfd0764559831fdd2e972abab0f34bc7300c650f6f789beea10ecb7d20251\"):\n", | ||
"\n", | ||
" pdf_file_path = pdf_path / \"eon.pdf\"\n", | ||
" pdf_content = pdf_file_path.read_bytes()\n", | ||
"\n", | ||
" print(dataland_client.documents_api.post_document(document=pdf_content))\n", | ||
"\n", | ||
"# change companyID in json file\n", | ||
"company_id = dataset[0].company_id\n", | ||
"\n", | ||
"json_file_path = json_path / \"eon.json\"\n", | ||
"with json_file_path.open(encoding=\"utf-8\") as f:\n", | ||
" json_data = json.load(f)\n", | ||
"\n", | ||
"json_data[\"companyID\"] = company_id\n", | ||
"\n", | ||
"with json_file_path.open(\"w\", encoding=\"utf-8\") as f:\n", | ||
" json.dump(json_data, f, indent=4)\n", | ||
"\n", | ||
"# upload data to dataland\n", | ||
"response = dataland_client.nuclear_and_gas_api.post_data(\n", | ||
" data=json_data\n", | ||
")\n", | ||
"\n", | ||
"print(dataset)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": ".venv", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.13.0" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |