Skip to content

Instantly share code, notes, and snippets.

@happyrainb
Created September 25, 2016 20:20
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 happyrainb/29ce31f062e56fb24d7f8d7f9ab1b2a3 to your computer and use it in GitHub Desktop.
Save happyrainb/29ce31f062e56fb24d7f8d7f9ab1b2a3 to your computer and use it in GitHub Desktop.
This script will insert record into ckan. Tested in testing site, never used in production. Made in 05/2016.
import ckanapi
mysite = ckanapi.RemoteCKAN('http://xxxx',
apikey='xxx',
user_agent='ckanapiexample/1.0 (+http://example.com/my/website)')
data = {
"title": "UrbanSound",
"license_title": "Creative Commons Attribution",
"maintainer": "",
"relationships_as_object": [
],
"private": False,
"maintainer_email": "",
"num_tags": 5,
"id": "7285f5c2-412a-4264-95fe-39c658d8be3e",
"metadata_created": "2015-10-06T22:39:59.411120",
"metadata_modified": "2016-03-29T19:03:06.079724",
"author": "Salamon, Justin (CUSP); Jacoby, Christopher (NYU); Bello, Juan Pablo (NYU)",
"author_email": "",
"state": "active",
"version": "",
"creator_user_id": "47585243-3956-410a-b723-6a6806d3f099",
"type": "dataset",
"resources": [
],
"num_resources": 0,
"tags": [
{
"vocabulary_id": None,
"state": "active",
"display_name": "audio",
"id": "ce75abd2-fe70-4b67-ade3-d6504bb5a572",
"name": "audio"
},
{
"vocabulary_id": None,
"state": "active",
"display_name": "recordings",
"id": "b0b06eea-f74d-4334-af3e-e9a5bfb4368a",
"name": "recordings"
},
{
"vocabulary_id": None,
"state": "active",
"display_name": "salience",
"id": "43c17ab2-9265-4dc3-ae1f-e1b80275c7e9",
"name": "salience"
},
{
"vocabulary_id": None,
"state": "active",
"display_name": "sounds",
"id": "ead751e1-de73-4bdd-9d2e-6b2ec1bc722a",
"name": "sounds"
},
{
"vocabulary_id": None,
"state": "active",
"display_name": "soundscape",
"id": "07d3f27b-cc62-4573-8b7c-f33067116497",
"name": "soundscape"
}
],
"groups": [
],
"license_id": "cc-by",
"relationships_as_subject": [
],
"organization": {
"description": "TEST DESCRIPTION",
"created": "2015-10-02T18:26:30.148219",
"title": "NYU CUSP",
"name": "cusp",
"is_organization": True,
"state": "active",
"image_url": "2015-10-02-222630.075834cusp-index.png",
"revision_id": "9d13b250-1caa-4aef-a823-7a044ffc8b65",
"type": "organization",
"id": "f1ade314-bd79-4437-8f3c-923c2f924569",
"approval_status": "approved"
},
"name": "hdlcusp10211",
"isopen": True,
"url": "",
"notes": "Over 1300 labeled sound recordings from 10 classes: air conditioner, car horn, children playing, dog bark, drilling, engine idling, gun shot, jackhammer, siren, and street music. Every recording is labeled with the start and end time of the sound event.Each recording may contain multiple sound events, but for each file only a single class is labeled. The classes are drawn from the urban sound taxonomy (refer to data access website provided below). All recordings were obtained from www.freesound.org. The files are presorted by sound event class. Every audio file is accompanied by two metadata files.For a detailed description of the dataset and how it was compiled see the corresponding data paper. \r\n\r\n__Companion Website: __https://serv.cusp.nyu.edu/projects/urbansounddataset/",
"owner_org": "1de1bfef-1450-4b1f-9783-aba1419a5fd4",
"extras": [
{
"key": "Access State",
"value": "Accessible"
},
{
"key": "Conditions",
"value": "Datasets compiled by Justin Salamon, Christopher Jacoby and Juan Pablo Bello. All files come from www.freesound.org. Please see FREESOUNDCREDITS.txt (included in the dataset) for an attribution list. The Urban Sound dataset is offered free of charge for non commercial use only under the terms of the Creative Commons Attribution Noncommercial License (by nc), version 3.0. "
},
{
"key": "Country/Nation",
"value": "United States"
},
{
"key": "DOI",
"value": "hdlcusp10211"
},
{
"key": "Data Citation",
"value": "Salamon, Justin; Jacoby, Christopher; Bello, Juan Pablo, 2014, \"Urban Sound\", http://hdl.handle.net/CUSP/10211 The Center for Urban Science + Progress [Distributor] V2 [Version]"
},
{
"key": "Data Citation - Paper",
"value": "J. Salamon, C. Jacoby and J.P. Bello, \"A Dataset and Taxonomy for Urban Sound Research\", 22nd ACM International Conference on Multimedia, Orlando USA, Nov. 2014."
},
{
"key": "Data Classification",
"value": "Green"
},
{
"key": "Data Steward",
"value": "Justin Salamon"
},
{
"key": "Deposit Date",
"value": "2014"
},
{
"key": "Disclaimer",
"value": "The datasets and their contents are made available on an as is basis and without warranties of any kind, including without limitation satisfactory quality and conformity, merchantability, fitness for a particular purpose, accuracy or completeness, or absence of errors. Subject to any liability that may not be excluded or limited by law, NYU is not liable for, and expressly excludes, all liability for loss or damage however and whenever caused to anyone by any use of the Urban Sound dataset or any part of it. "
},
{
"key": "Distribution Date",
"value": "2014"
},
{
"key": "Distributor",
"value": "The Center for Urban Science + Progress (CUSP), New York University "
},
{
"key": "Geographic Bounding",
"value": "West Bounding Longitude: -74.144839 East Bounding Longitude: -73.866667 North Bounding Latitude: 40.837222 South Bounding Latitude: 40.576281"
},
{
"key": "Kind of Data",
"value": "audio files, .wav, accompanied by two metadata files, .json and .csv"
},
{
"key": "Original Dataverse",
"value": "The Center for Urban Science and Progress Dataverse"
},
{
"key": "Producer",
"value": "Music and Audio Research Laboratory (MARL), New York University ; Center for Urban Science and Progress (CUSP), New York University "
},
{
"key": "Production Date",
"value": "2014"
},
{
"key": "Production Place",
"value": "New York City"
},
{
"key": "Related Data",
"value": "Urban Sound 8K"
},
{
"key": "Related Material",
"value": "J. Salamon, C. Jacoby and J.P. Bello, \"A Dataset and Taxonomy for Urban Sound Research\", 22nd ACM International Conference on Multimedia, Orlando USA, Nov. 2014."
},
{
"key": "Study Global ID",
"value": "hdl:CUSP/10211"
},
{
"key": "Topic Classification",
"value": "Acoustics (CUSP); Environment (CUSP); Noise (CUSP); Remote Sensing (CUSP)"
}
],
"license_url": "http://www.opendefinition.org/licenses/cc-by",
"revision_id": "db995f5d-07bc-4f7f-86cb-b1e68c969558"
}
data2 = {
"title": "Some New Dataset",
"license_title": "Creative Commons Attribution",
"maintainer": "",
"relationships_as_object": [
],
"private": False,
"maintainer_email": "",
"num_tags": 5,
"id": "7285f5c2-412a-4264-95fe-39c658d8be3e",
"metadata_created": "2015-10-06T22:39:59.411120",
"metadata_modified": "2016-03-29T19:03:06.079724",
"author": "Salamon, Justin (CUSP); Jacoby, Christopher (NYU); Bello, Juan Pablo (NYU)",
"author_email": "",
"state": "active",
"version": "",
"creator_user_id": "47585243-3956-410a-b723-6a6806d3f099",
"type": "dataset",
"resources": [
],
"num_resources": 0,
"tags": [
{
"vocabulary_id": None,
"state": "active",
"display_name": "audio",
"id": "ce75abd2-fe70-4b67-ade3-d6504bb5a572",
"name": "audio"
},
{
"vocabulary_id": None,
"state": "active",
"display_name": "recordings",
"id": "b0b06eea-f74d-4334-af3e-e9a5bfb4368a",
"name": "recordings"
},
{
"vocabulary_id": None,
"state": "active",
"display_name": "salience",
"id": "43c17ab2-9265-4dc3-ae1f-e1b80275c7e9",
"name": "salience"
},
{
"vocabulary_id": None,
"state": "active",
"display_name": "sounds",
"id": "ead751e1-de73-4bdd-9d2e-6b2ec1bc722a",
"name": "sounds"
},
{
"vocabulary_id": None,
"state": "active",
"display_name": "soundscape",
"id": "07d3f27b-cc62-4573-8b7c-f33067116497",
"name": "soundscape"
}
],
"groups": [
],
"license_id": "cc-by",
"relationships_as_subject": [
],
"organization": {
"state": "active",
"image_url": "2015-10-02-222630.075834cusp-index.png",
"revision_id": "9d13b250-1caa-4aef-a823-7a044ffc8b65",
"type": "organization",
"id": "f1ade314-bd79-4437-8f3c-923c2f924569",
"approval_status": "approved"
"description": "TEST DESCRIPTION",
"created": "2015-10-02T18:26:30.148219",
"title": "NYU CUSP",
"name": "cusp",
"is_organization": True,
},
"name": "hdlcusp10211",
"isopen": True,
"url": "",
"notes": "Over 1300 labeled sound recordings from 10 classes: air conditioner, car horn, children playing, dog bark, drilling, engine idling, gun shot, jackhammer, siren, and street music. Every recording is labeled with the start and end time of the sound event.Each recording may contain multiple sound events, but for each file only a single class is labeled. The classes are drawn from the urban sound taxonomy (refer to data access website provided below). All recordings were obtained from www.freesound.org. The files are presorted by sound event class. Every audio file is accompanied by two metadata files.For a detailed description of the dataset and how it was compiled see the corresponding data paper. \r\n\r\n__Companion Website: __https://serv.cusp.nyu.edu/projects/urbansounddataset/",
"owner_org": "1de1bfef-1450-4b1f-9783-aba1419a5fd4",
"extras": [
{
"key": "Access State",
"value": "Accessible"
},
{
"key": "Conditions",
"value": "Datasets compiled by Justin Salamon, Christopher Jacoby and Juan Pablo Bello. All files come from www.freesound.org. Please see FREESOUNDCREDITS.txt (included in the dataset) for an attribution list. The Urban Sound dataset is offered free of charge for non commercial use only under the terms of the Creative Commons Attribution Noncommercial License (by nc), version 3.0. "
},
{
"key": "Country/Nation",
"value": "United States"
},
{
"key": "DOI",
"value": "hdlcusp10211"
},
{
"key": "Data Citation",
"value": "Salamon, Justin; Jacoby, Christopher; Bello, Juan Pablo, 2014, \"Urban Sound\", http://hdl.handle.net/CUSP/10211 The Center for Urban Science + Progress [Distributor] V2 [Version]"
},
{
"key": "Data Citation - Paper",
"value": "J. Salamon, C. Jacoby and J.P. Bello, \"A Dataset and Taxonomy for Urban Sound Research\", 22nd ACM International Conference on Multimedia, Orlando USA, Nov. 2014."
},
{
"key": "Data Classification",
"value": "Green"
},
{
"key": "Data Steward",
"value": "Justin Salamon"
},
{
"key": "Deposit Date",
"value": "2014"
},
{
"key": "Disclaimer",
"value": "The datasets and their contents are made available on an as is basis and without warranties of any kind, including without limitation satisfactory quality and conformity, merchantability, fitness for a particular purpose, accuracy or completeness, or absence of errors. Subject to any liability that may not be excluded or limited by law, NYU is not liable for, and expressly excludes, all liability for loss or damage however and whenever caused to anyone by any use of the Urban Sound dataset or any part of it. "
},
{
"key": "Distribution Date",
"value": "2014"
},
{
"key": "Distributor",
"value": "The Center for Urban Science + Progress (CUSP), New York University "
},
{
"key": "Geographic Bounding",
"value": "West Bounding Longitude: -74.144839 East Bounding Longitude: -73.866667 North Bounding Latitude: 40.837222 South Bounding Latitude: 40.576281"
},
{
"key": "Kind of Data",
"value": "audio files, .wav, accompanied by two metadata files, .json and .csv"
},
{
"key": "Original Dataverse",
"value": "The Center for Urban Science and Progress Dataverse"
},
{
"key": "Producer",
"value": "Music and Audio Research Laboratory (MARL), New York University ; Center for Urban Science and Progress (CUSP), New York University "
},
{
"key": "Production Date",
"value": "2014"
},
{
"key": "Production Place",
"value": "New York City"
},
{
"key": "Related Data",
"value": "Urban Sound 8K"
},
{
"key": "Related Material",
"value": "J. Salamon, C. Jacoby and J.P. Bello, \"A Dataset and Taxonomy for Urban Sound Research\", 22nd ACM International Conference on Multimedia, Orlando USA, Nov. 2014."
},
{
"key": "Study Global ID",
"value": "hdl:CUSP/10211"
},
{
"key": "Topic Classification",
"value": "Acoustics (CUSP); Environment (CUSP); Noise (CUSP); Remote Sensing (CUSP)"
}
],
"license_url": "http://www.opendefinition.org/licenses/cc-by",
"revision_id": "db995f5d-07bc-4f7f-86cb-b1e68c969558"
}
datasets = []
datasets.append(data)
datasets.append(data2)
for dataset in datasets:
mysite.call_action('package_create', data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment