Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save robkooper/6a241af10919702356cc431b57dc0145 to your computer and use it in GitHub Desktop.
Save robkooper/6a241af10919702356cc431b57dc0145 to your computer and use it in GitHub Desktop.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "7b7cfba6",
"metadata": {
"execution": {
"iopub.execute_input": "2021-07-07T21:11:03.687260Z",
"iopub.status.busy": "2021-07-07T21:11:03.686663Z",
"iopub.status.idle": "2021-07-07T21:11:03.689677Z",
"shell.execute_reply": "2021-07-07T21:11:03.689139Z"
},
"papermill": {
"duration": 0.011374,
"end_time": "2021-07-07T21:11:03.689821",
"exception": false,
"start_time": "2021-07-07T21:11:03.678447",
"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"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "cbeaf5c6",
"metadata": {
"execution": {
"iopub.execute_input": "2021-07-07T21:11:03.701221Z",
"iopub.status.busy": "2021-07-07T21:11:03.700676Z",
"iopub.status.idle": "2021-07-07T21:11:03.703101Z",
"shell.execute_reply": "2021-07-07T21:11:03.703533Z"
},
"papermill": {
"duration": 0.009345,
"end_time": "2021-07-07T21:11:03.703674",
"exception": false,
"start_time": "2021-07-07T21:11:03.694329",
"status": "completed"
},
"tags": [
"parameters"
]
},
"outputs": [],
"source": [
"#url = "
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "7aba89eb",
"metadata": {
"execution": {
"iopub.execute_input": "2021-07-07T21:11:03.717501Z",
"iopub.status.busy": "2021-07-07T21:11:03.716829Z",
"iopub.status.idle": "2021-07-07T21:11:03.719475Z",
"shell.execute_reply": "2021-07-07T21:11:03.719060Z"
},
"papermill": {
"duration": 0.012212,
"end_time": "2021-07-07T21:11:03.719601",
"exception": false,
"start_time": "2021-07-07T21:11:03.707389",
"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": 4,
"id": "409a7994",
"metadata": {
"execution": {
"iopub.execute_input": "2021-07-07T21:11:03.731391Z",
"iopub.status.busy": "2021-07-07T21:11:03.730803Z",
"iopub.status.idle": "2021-07-07T21:11:03.732951Z",
"shell.execute_reply": "2021-07-07T21:11:03.733328Z"
},
"papermill": {
"duration": 0.010294,
"end_time": "2021-07-07T21:11:03.733463",
"exception": false,
"start_time": "2021-07-07T21:11:03.723169",
"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": 5,
"id": "56bdb705",
"metadata": {
"execution": {
"iopub.execute_input": "2021-07-07T21:11:03.743835Z",
"iopub.status.busy": "2021-07-07T21:11:03.743329Z",
"iopub.status.idle": "2021-07-07T21:11:04.268445Z",
"shell.execute_reply": "2021-07-07T21:11:04.268034Z"
},
"papermill": {
"duration": 0.531645,
"end_time": "2021-07-07T21:11:04.268573",
"exception": false,
"start_time": "2021-07-07T21:11:03.736928",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"df=read_file(url)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "dc48b7cc",
"metadata": {
"execution": {
"iopub.execute_input": "2021-07-07T21:11:04.285352Z",
"iopub.status.busy": "2021-07-07T21:11:04.284749Z",
"iopub.status.idle": "2021-07-07T21:11:04.304303Z",
"shell.execute_reply": "2021-07-07T21:11:04.303769Z"
},
"papermill": {
"duration": 0.031852,
"end_time": "2021-07-07T21:11:04.304417",
"exception": false,
"start_time": "2021-07-07T21:11:04.272565",
"status": "completed"
},
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Date</th>\n",
" <th>Sample</th>\n",
" <th>Experiment_num</th>\n",
" <th>Time</th>\n",
" <th>Replication</th>\n",
" <th>Volume_Filtered_mL</th>\n",
" <th>Extract_Volume_mL</th>\n",
" <th>Dilution_Factor</th>\n",
" <th>F_o</th>\n",
" <th>F_o_blank</th>\n",
" <th>F_a</th>\n",
" <th>F_a_blank</th>\n",
" <th>Total_chl_with_phaeo</th>\n",
" <th>Total_Chl_no_phaeo</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>May 16 2017</td>\n",
" <td>100% WSW</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>135</td>\n",
" <td>6</td>\n",
" <td>1</td>\n",
" <td>16.5</td>\n",
" <td>16.5</td>\n",
" <td>9.72</td>\n",
" <td>9.72</td>\n",
" <td>0.73</td>\n",
" <td>0.63</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>May 16 2017</td>\n",
" <td>100% WSW</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>140</td>\n",
" <td>6</td>\n",
" <td>1</td>\n",
" <td>15.9</td>\n",
" <td>15.9</td>\n",
" <td>9.63</td>\n",
" <td>9.63</td>\n",
" <td>0.68</td>\n",
" <td>0.56</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>May 16 2017</td>\n",
" <td>100% WSW</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>135</td>\n",
" <td>6</td>\n",
" <td>1</td>\n",
" <td>16.9</td>\n",
" <td>16.9</td>\n",
" <td>9.93</td>\n",
" <td>9.93</td>\n",
" <td>0.75</td>\n",
" <td>0.65</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>May 17 2017</td>\n",
" <td>HHQ DMSO A</td>\n",
" <td>1</td>\n",
" <td>24</td>\n",
" <td>1</td>\n",
" <td>135</td>\n",
" <td>6</td>\n",
" <td>1</td>\n",
" <td>22.9</td>\n",
" <td>22.9</td>\n",
" <td>12.80</td>\n",
" <td>12.80</td>\n",
" <td>1.01</td>\n",
" <td>0.94</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>May 17 2017</td>\n",
" <td>HHQ DMSO B</td>\n",
" <td>1</td>\n",
" <td>24</td>\n",
" <td>2</td>\n",
" <td>135</td>\n",
" <td>6</td>\n",
" <td>1</td>\n",
" <td>21.0</td>\n",
" <td>21.0</td>\n",
" <td>12.30</td>\n",
" <td>12.30</td>\n",
" <td>0.93</td>\n",
" <td>0.81</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>67</th>\n",
" <td>May 31 2017</td>\n",
" <td>HHQ DMSO B</td>\n",
" <td>8</td>\n",
" <td>24</td>\n",
" <td>2</td>\n",
" <td>135</td>\n",
" <td>6</td>\n",
" <td>1</td>\n",
" <td>11.4</td>\n",
" <td>11.4</td>\n",
" <td>6.49</td>\n",
" <td>6.49</td>\n",
" <td>0.50</td>\n",
" <td>0.46</td>\n",
" </tr>\n",
" <tr>\n",
" <th>68</th>\n",
" <td>May 31 2017</td>\n",
" <td>HHQ DMSO C</td>\n",
" <td>8</td>\n",
" <td>24</td>\n",
" <td>3</td>\n",
" <td>135</td>\n",
" <td>6</td>\n",
" <td>1</td>\n",
" <td>13.7</td>\n",
" <td>13.7</td>\n",
" <td>8.56</td>\n",
" <td>8.56</td>\n",
" <td>0.60</td>\n",
" <td>0.48</td>\n",
" </tr>\n",
" <tr>\n",
" <th>69</th>\n",
" <td>May 31 2017</td>\n",
" <td>HHQ Hi A</td>\n",
" <td>8</td>\n",
" <td>24</td>\n",
" <td>1</td>\n",
" <td>135</td>\n",
" <td>6</td>\n",
" <td>1</td>\n",
" <td>12.5</td>\n",
" <td>12.5</td>\n",
" <td>7.74</td>\n",
" <td>7.74</td>\n",
" <td>0.55</td>\n",
" <td>0.44</td>\n",
" </tr>\n",
" <tr>\n",
" <th>70</th>\n",
" <td>May 31 2017</td>\n",
" <td>HHQ Hi B</td>\n",
" <td>8</td>\n",
" <td>24</td>\n",
" <td>2</td>\n",
" <td>135</td>\n",
" <td>6</td>\n",
" <td>1</td>\n",
" <td>17.6</td>\n",
" <td>17.6</td>\n",
" <td>10.60</td>\n",
" <td>10.60</td>\n",
" <td>0.78</td>\n",
" <td>0.65</td>\n",
" </tr>\n",
" <tr>\n",
" <th>71</th>\n",
" <td>May 31 2017</td>\n",
" <td>HHQ Hi C</td>\n",
" <td>8</td>\n",
" <td>24</td>\n",
" <td>3</td>\n",
" <td>135</td>\n",
" <td>6</td>\n",
" <td>1</td>\n",
" <td>14.5</td>\n",
" <td>14.5</td>\n",
" <td>8.64</td>\n",
" <td>8.64</td>\n",
" <td>0.64</td>\n",
" <td>0.55</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>72 rows × 14 columns</p>\n",
"</div>"
],
"text/plain": [
" Date Sample Experiment_num Time Replication \\\n",
"0 May 16 2017 100% WSW 1 0 1 \n",
"1 May 16 2017 100% WSW 1 0 2 \n",
"2 May 16 2017 100% WSW 1 0 3 \n",
"3 May 17 2017 HHQ DMSO A 1 24 1 \n",
"4 May 17 2017 HHQ DMSO B 1 24 2 \n",
".. ... ... ... ... ... \n",
"67 May 31 2017 HHQ DMSO B 8 24 2 \n",
"68 May 31 2017 HHQ DMSO C 8 24 3 \n",
"69 May 31 2017 HHQ Hi A 8 24 1 \n",
"70 May 31 2017 HHQ Hi B 8 24 2 \n",
"71 May 31 2017 HHQ Hi C 8 24 3 \n",
"\n",
" Volume_Filtered_mL Extract_Volume_mL Dilution_Factor F_o F_o_blank \\\n",
"0 135 6 1 16.5 16.5 \n",
"1 140 6 1 15.9 15.9 \n",
"2 135 6 1 16.9 16.9 \n",
"3 135 6 1 22.9 22.9 \n",
"4 135 6 1 21.0 21.0 \n",
".. ... ... ... ... ... \n",
"67 135 6 1 11.4 11.4 \n",
"68 135 6 1 13.7 13.7 \n",
"69 135 6 1 12.5 12.5 \n",
"70 135 6 1 17.6 17.6 \n",
"71 135 6 1 14.5 14.5 \n",
"\n",
" F_a F_a_blank Total_chl_with_phaeo Total_Chl_no_phaeo \n",
"0 9.72 9.72 0.73 0.63 \n",
"1 9.63 9.63 0.68 0.56 \n",
"2 9.93 9.93 0.75 0.65 \n",
"3 12.80 12.80 1.01 0.94 \n",
"4 12.30 12.30 0.93 0.81 \n",
".. ... ... ... ... \n",
"67 6.49 6.49 0.50 0.46 \n",
"68 8.56 8.56 0.60 0.48 \n",
"69 7.74 7.74 0.55 0.44 \n",
"70 10.60 10.60 0.78 0.65 \n",
"71 8.64 8.64 0.64 0.55 \n",
"\n",
"[72 rows x 14 columns]"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"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.8.10"
},
"papermill": {
"default_parameters": {},
"duration": 1.805243,
"end_time": "2021-07-07T21:11:04.514371",
"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-07T21:11:02.709128",
"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