Last active
January 11, 2017 18:21
-
-
Save MikeTrizna/531b09ad07832fbd46861b16ae59afe7 to your computer and use it in GitHub Desktop.
This GIST illustrates some issues with the new tab REST endpoint.
This file contains hidden or 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, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"import requests" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"http://biscicol.org/biocode-fims/rest/v1.1/projects/query/tab?expeditions=NMK_JSK_002&projectId=8\n" | |
] | |
} | |
], | |
"source": [ | |
"dataset_url = 'http://biscicol.org/biocode-fims/rest/v1.1/projects/query/tab'\n", | |
"payload = {'projectId': '8',\n", | |
" 'expeditions': 'NMK_JSK_002'}\n", | |
"dataset_r = requests.get(dataset_url, params=payload)\n", | |
"print(dataset_r.url)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Line: 1\n", | |
"voucherID,institutionCode,catalogNumber,chainOfCustody,processingLab,extractionPlateID,extractionWell,yearCollected,monthCollected,dayCollected,collectedBy,countryOrOcean,scientificName,kingdom,phylum,genus,species,tissueBarcode,sequencingLab,tissueRack,tissuePosition,tissueType,collectionCode,decimalLatitude,decimalLongitude,coordinatePrecision,identifiedBy,yearIdentified,monthIdentified,dayIdentified,typeStatus,basisOfID,identificationConfidence,class,order,family,extractionPlateBarcode,tissueRackBarcode,preservative,extractionBarcode,sex,lifeStage,associatedMedia,establishmentMeans,sampleRemarks,eventID,collectionMethod,fieldNumber,timeCollected,permitInformation,habitat,eventRemarks,waterBody,island,stateProvince,county,municipality,locality,verbatimElevation,verbatimDepth,locationRemarks,georeferenceProtocol,subfamily,subspecies,commonName,associatedTaxa,taxonRemarks,bcid,\n", | |
"Line: 2\n", | |
"NMK:833:10211,NMK,10211,No,IPR-MBL,NMK_JSK_002,G04,2014,9,26,Kamau et al.,Kenya,Euphorbia sp.,Plantae,Tracheophyta,Euphorbia,sp.,FR04505371,BecA-ILRI,JSK_002,B06,Leaf,EA,03 57.800-,38 57.200,-1,Nyamolo,2014,10,17,other,ID KEY & Guide,High,Magnoliopsida,Malphigiales,Euphorbiaceae,50051567,SA00033718,Silica beads,FR06482696,undetermined,adult,DCNO474-476,native,,BWPK,By hand,833,Afternoon,,Coastal forest,,,,Coast,Kwale,Kinango,Kilibasi hill,,,,\"Garmin GPS handset, Datum WGS84\",,,,,,ark:/21547/Zb2FR04505371,\n", | |
"Line: 3\n", | |
"NMK:9592:10225,NMK,10225,No,IPR-MBL,NMK_JSK_002,E06,2014,9,25,Mwadime et al.,Kenya,Liparis nervosa,Plantae,Magnoliophyta,Liparis,malacophylla,FR04505280,BecA-ILRI,JSK_002,D08,Leaf,EA,0 21 10.7000-,34 51 39.8000,-1,Dr. Khayota & Mwadime N,2014,10,17,other,ID KEY & Guide,High,Liliopsida,Asparagales,Orchidaceae,50051567,SA00033718,Silica beads,FR06482710,undetermined,adult,,native,,BWPK,By hand,959.2,Afternoon,,Tropical rain forest,,,,Western,Kakamega,Kakamega,Kakamega Forest,1683.9,,,\"Garmin GPS handset, Datum WGS84\",,,,,,ark:/21547/Zb2FR04505280,\n", | |
"Line: 4\n", | |
"NMK:824:10204,NMK,10204,No,IPR-MBL,NMK_JSK_002,H03,2014,9,25,Kamau et al.,Kenya,Polystachya cultriformis,Plantae,Magnoliophyta,Polystachya,cultriformis,FR04505383,BecA-ILRI,JSK_002,A05,Leaf,EA,03 24.800-,38 17.700,-1,Nyamolo,2014,10,17,other,ID KEY & Guide,High,Liliopsida,Asparagales,Orchidaceae,50051567,SA00033718,Silica beads,FR06482689,undetermined,adult,DCNO382-385,native,,BWPK,By hand,824,Afternoon,,Coastal forest,,,,Coast,Taita Taveta,Wundayi,Vuria hill,,,,\"Garmin GPS handset, Datum WGS84\",,,,,,ark:/21547/Zb2FR04505383,\n", | |
"Line: 5\n", | |
"NMK:839:10217,NMK,10217,No,IPR-MBL,NMK_JSK_002,E05,2014,9,26,Kamau et al.,Kenya,Angraecum cultriforme,Plantae,Magnoliophyta,Angraecum,cultriforme,FR04505313,BecA-ILRI,JSK_002,B07,Leaf,EA,03 57.700-,38 57.200,-1,Nyamolo,2014,10,17,other,ID KEY & Guide,High,Liliopsida,Asparagales,Orchidaceae,50051567,SA00033718,Silica beads,FR06482702,undetermined,adult,\"DCNO524,526,528,532\",native,,BWPK,By hand,839,Afternoon,,Coastal forest,,,,Coast,Kwale,Kinango,Kilibasi hill,,,,\"Garmin GPS handset, Datum WGS84\",,,,,,ark:/21547/Zb2FR04505313,\n" | |
] | |
} | |
], | |
"source": [ | |
"#Split return text by new-line character, and subset to only first 5 lines\n", | |
"return_lines = dataset_r.text.split('\\n')[:5]\n", | |
"for line_number, line_text in enumerate(return_lines):\n", | |
" print('Line:',line_number+1)\n", | |
" print(line_text)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"anaconda-cloud": {}, | |
"kernelspec": { | |
"display_name": "Python [default]", | |
"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.5.2" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment