Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smrgeoinfo/bc813f0246563149c4633dbc256d7730 to your computer and use it in GitHub Desktop.
Save smrgeoinfo/bc813f0246563149c4633dbc256d7730 to your computer and use it in GitHub Desktop.
GIST created by python code
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "a82e4c49",
"metadata": {
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"#Before constructing a gist, I will try creating the file and opening it in jupyterhub\n",
"#so 1st call a rest service to construct the pre-gist, then can open it: ;on jh have shared vars, but want elsewhere\n",
"#now instead of having to have url, need nb-name to open, but that will be clicked on in the ui\n",
"# http://141.142.218.86:8081/notebooks/https/darchive.mblwhoilibrary.org/bitstream/1912/26532/1/dataset-752737_bergen-mesohux-2017-dissolved-nutrients__v1.tsv.ipynb\n",
"# http://141.142.218.86:8081/notebooks/jup-nb-arg-in-url.ipynb?kernel_name=python3&dwn1=https://darchive.mblwhoilibrary.org/bitstream/1912/26532/1/dataset-752737_bergen-mesohux-2017-dissolved-nutrients__v1.tsv#\n",
"#url = \"https://darchive.mblwhoilibrary.org/bitstream/1912/23805/1/dataset-753388_hhq-chlorophyll__v1.tsv\" #for now\n",
"#might construct this w/: https://github.com/nteract/papermill"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d5b95abb",
"metadata": {
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "completed"
},
"tags": [
"parameters"
]
},
"outputs": [],
"source": [
"#url = "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a674f3ee",
"metadata": {
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "completed"
},
"tags": [
"injected-parameters"
]
},
"outputs": [],
"source": [
"# Parameters\n",
"url = \"https://darchive.mblwhoilibrary.org/bitstream/1912/23805/1/dataset-753388_hhq-chlorophyll__v1.tsv\"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "735b83da",
"metadata": {
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"#!pip install pandas\n",
"def read_file(fn):\n",
" \"can be a url, will call pd read_.. for the ext type\"\n",
" import pandas as pd\n",
" import os\n",
" st=os.path.splitext(fn)\n",
" ft=st[-1]\n",
" if ft=='.tsv':\n",
" df=pd.read_csv(fn, sep='\\t')\n",
" elif ft=='.csv':\n",
" df=pd.read_csv(fn)\n",
" else:\n",
" df=\"no reader, can !wget the file\"\n",
" return df"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "135c6cbe",
"metadata": {
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"df=read_file(url)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cbe19d62",
"metadata": {
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"df"
]
}
],
"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.7.4"
},
"papermill": {
"default_parameters": {},
"duration": 2.28413,
"end_time": "2021-07-07T20:54:09.487806",
"environment_variables": {},
"exception": null,
"input_path": "mybinder-read-pre-gist.ipynb",
"output_path": "https/darchive.mblwhoilibrary.org_bitstream_1912_23805_1_dataset-753388_hhq-chlorophyll__v1.tsv.ipynb",
"parameters": {
"url": "https://darchive.mblwhoilibrary.org/bitstream/1912/23805/1/dataset-753388_hhq-chlorophyll__v1.tsv"
},
"start_time": "2021-07-07T20:54:07.203676",
"version": "2.3.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment