Skip to content

Deleting nwb files from dandisets #139

Closed Answered by CodyCBakerPhD
GiedreSilk asked this question in Q&A
Discussion options

You must be logged in to vote

Not through the website, but you can do these via the Python API

Set an environment variable called DANDI_API_KEY equal to your usual DANDI token

import os
from pathlib import Path

from dandi.dandiapi import DandiAPIClient

# Form a list of filenames you wish to delete; e.g., `sub-ABC_ses-123.nwb`
dandi_file_paths_to_remove = [...]

client = DandiAPIClient(token=os.environ["DANDI_API_KEY"])
dandiset = client.get_dandiset(dandiset_id="<enter your six-digit dandiset ID>")
assets = list(dandiset.get_assets())  # This fetches all live assets on the dandiset

assets_to_remove = [asset for asset in assets if Path(assets.path).name in dandi_file_paths_to_remove]

# The batch delete command
for a…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@GiedreSilk
Comment options

Answer selected by GiedreSilk
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants