Lightweight Dataverse interface in Python to upload, download and update datasets found in Dataverse instances.
Project description
EasyDataverse is a Python library used to interface Dataverse installations and dynamically generate Python objects compatible to a metadatablock configuration given at a Dataverse installation. In addition, EasyDataverse allows you to export and import datasets to and from various data formats.
Features
- Metadataconfig compliant classes for flexible Dataset creation.
- Upload and download of files and directories to and from Dataverse installations.
- Export and import of datasets to various formats (JSON, YAML and XML).
- Fetch datasets from any Dataverse installation into an object oriented structure ready to be integrated.
⚡️ Quick start
Get started with EasyDataverse by running the following command
# Using PyPI
pip install easyDataverse
Or build by source
pip install git+https://github.com/gdcc/easyDataverse.git
⚙️ Quickstart
Dataset creation
EasyDataverse is capable of connecting to a given Dataverse installation and fetch all metadata fields and their properties. This allows you to create a dataset object with all the metadata fields and their properties given at the Dataverse installation.
from easyDataverse import Dataverse
# Connect to a Dataverse installation
dataverse = Dataverse(
server_url="https://demo.dataverse.org",
api_token="MY_API_TOKEN",
)
# Initialize a dataset
dataset = dataverse.create_dataset()
# Fill metadata blocks
dataset.citation.title = "My dataset"
dataset.citation.subject = ["Other"]
dataset.citation.add_author(name="John Doe")
dataset.citation.add_dataset_contact(name="John Doe", email="john@doe.com")
dataset.citation.add_ds_description(value="This is a description of the dataset")
# Upload files or directories
dataset.add_file(local_path="./my.file", dv_dir="some/dir")
dataset.add_directory(dirpath="./my_directory", dv_dir="some/dir")
# Upload to the dataverse instance
dataset.upload("my_dataverse_id")
Dataset download and update
EasyDataset allows you to download datasets from any Dataverse installation. The downloaded dataset is represented as an object oriented structure and can be used to update metadata/files, export a dataset to various formats or use it in subsequent applications.
# Method 1: Download a dataset by its DOI
dataverse = Dataverse("https://demo.dataverse.org")
dataset = dataverse.load_dataset(
pid="doi:10.70122/FK2/W5AGKD",
version="1",
filedir="place/for/data",
)
# Method 2: Download via URL
dataset, dataverse = Dataverse.from_ds_url(
url="https://demo.dataverse.org/dataset.xhtml?persistentId=doi:10.70122/XX/XXXXX&version=DRAFT",
api_token="MY_API_TOKEN"
)
# Display the content of the dataset
print(dataset)
# Update metadata
dataset.citation.title = "My even nicer dataset"
# Synchronize with the dataverse instance
dataset.update()
📖 Documentation and more examples
🚧 Under construction 🚧
✍️ Authors
- Jan Range (EXC2075 SimTech, University of Stuttgart)
⚠️ License
EasyDataverse
is free and open-source software licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file easydataverse-0.4.1.tar.gz
.
File metadata
- Download URL: easydataverse-0.4.1.tar.gz
- Upload date:
- Size: 21.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.1 Linux/6.5.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2697c2fc49b7f12e667d1d0c4f2f6b8c3f802c9e9e079d7d52226c5db78631aa |
|
MD5 | 3ba756ab69e30f310b20d2ee40bd4999 |
|
BLAKE2b-256 | ca9341018ed25aa47ed005ad569a488cc60083376457483f3fbc59f707bb732a |
File details
Details for the file easydataverse-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: easydataverse-0.4.1-py3-none-any.whl
- Upload date:
- Size: 24.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.1 Linux/6.5.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 757b532c9b98349e992c78a76b50d36cc86be0067446ea21f1a4330c9b282309 |
|
MD5 | 39be3452aa7076b33e0eb1b451bdb10d |
|
BLAKE2b-256 | 0e62edc46b83f6da6007d32ef062d01da2124cd5558aea6d721adafccf37a494 |