gdcc / easyDataverse

🪐 - Lightweight Dataverse interface in Python to upload, download and update datasets found in Dataverse installations.
MIT License
16 stars 5 forks source link

Add `categories` kwargs - fixes #15 #17

Closed JR-1991 closed 7 months ago

JR-1991 commented 8 months ago

As highlighted in #15, the current version of EasyDataverse does not offer ways to add tags to data files. Thus, the add_file method of the Dataset class has been extended to accept categories as a keyword argument.

Please note that the add_directory function cannot accept such tags. Instead, it is best to directly edit the categories attribute of a File object found in dataset.files after adding a complete directory.

Closes #15

Example

from easyDataverse import Dataverse

dataverse = Dataverse(SERVER_URL, API_TOKEN)
dataset  = dataverse.create_dataset()
dataset.add_file(
        local_path="path/to/my.file",
        dv_dir="some/sub/dir",
        categories=["My Tag", "Another tag"],
        description="This is a description",
    )