Created
October 12, 2022 17:32
-
-
Save MrHamel/145e0eb19415cd07a8a45568e36f7f7f to your computer and use it in GitHub Desktop.
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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"id": "c26915ad", | |
"metadata": { | |
"papermill": {}, | |
"tags": [ | |
"parameters" | |
] | |
}, | |
"outputs": [], | |
"source": [ | |
"#github.com/nteract/papermill'parameters'tag used to inject them into template then post a gist runable by colab\n", | |
"%load_ext rpy2.ipython\n", | |
"%load_ext google.colab.data_table\n", | |
"import httpimport\n", | |
"with httpimport.github_repo('MBcode', 'ec'):\n", | |
" import ec\n", | |
"#ec.get_ec() #work from scratch version for a bit\n", | |
"#import ec\n", | |
"q=\"norway\" #an example query" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "2bf31ddc", | |
"metadata": { | |
"tags": [ | |
"injected-parameters" | |
] | |
}, | |
"outputs": [], | |
"source": [ | |
"# Parameters\n", | |
"url = None\n", | |
"ext = None\n", | |
"urn = None\n", | |
"q = \"Ridgecrest\"\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"id": "6c899634", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"dfSPARQL=ec.txt_query(q)\n", | |
"dfSPARQL" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"id": "4dccd0f7", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"#Can cut URN from the g_column and use as the URN, from Row of interest:\n", | |
"urn=dfSPARQL['g'][0] #or put the row you want to use here\n", | |
"urn=None #paste the URN from g in a quotes here\n", | |
"dfRDF=ec.wget_rdf(urn)\n", | |
"#!ls -l or FilePaneBrowser on left, to see it\n", | |
"dfRDF" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"id": "442b7c28", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"#Can cut url and ext from the same Row of interest:\n", | |
"urls=ec.dfRow2urls(df,1) #or put in another row number to get url\n", | |
"urls" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"id": "7d66149e", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"#Can cut url and ext from the same Row of interest (or default to value from row):\n", | |
"url,ext=urls[0][1],None\n", | |
"df=ec.read_file(url,ext)\n", | |
"df" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"id": "c572c10d", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"#dataset page functionality includes: search_relateddatafilename\n", | |
" #and tool matches: search_download search_webservice search_notebook\n", | |
"!ls -l" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"id": "b10f1056", | |
"metadata": { | |
"papermill": {}, | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"!ls -l \n", | |
"ec.viz() #shows .nt metadata from urn, can use for (rdf)xml as well " | |
] | |
} | |
], | |
"metadata": { | |
"celltoolbar": "Tags", | |
"kernelspec": { | |
"display_name": "Python 3", | |
"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.8.10" | |
}, | |
"papermill": { | |
"default_parameters": {}, | |
"environment_variables": {}, | |
"input_path": "/app/templates/sparql.ipynb", | |
"output_path": "/tmp/q_Ridgecrest.ipynb", | |
"parameters": { | |
"ext": null, | |
"q": "Ridgecrest", | |
"url": null, | |
"urn": null | |
}, | |
"version": "2.4.0" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment