-
-
Save suriyan/ffe979445a8f419c10bc939419062fc9 to your computer and use it in GitHub Desktop.
Upload files to the Dataverse
This file contains 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
""" | |
Upload files to the Dataverse | |
Requirements:- | |
``` | |
pip install dataverse | |
``` | |
""" | |
from glob import glob | |
from dataverse import Connection | |
# Dataverse API Token | |
# https://dataverse.harvard.edu/dataverseuser.xhtml?selectTab=apiTokenTab | |
API_TOKEN = '<API TOKEN>' | |
DATAVERSE = '<DATAVERSE e.g. sawasdee>' | |
DATASET_DOI = '<DATASET DOI e.g. doi:10.7910/DVN/MQPPNC>' | |
HOST = 'dataverse.harvard.edu' | |
conn = Connection(HOST, API_TOKEN) | |
dv = conn.get_dataverse(DATAVERSE) | |
ds = dv.get_dataset_by_doi(DATASET_DOI) | |
### Upload file to dataset (e.g. *.tar.gz from the current directory) | |
for fn in sorted(glob('*.tar.gz'): | |
print(fn) | |
ds.upload_filepaths([fn]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment