Skip to content

How to: get the list of files in a dataset

Baptiste Vandecrux edited this page Mar 26, 2021 · 2 revisions

See a solution in Python in dataverse-export.py

import json
import requests  # http://docs.python-requests.org/en/master/
from pyDataverse.api import NativeApi

dataverse_server = 'https://dataverse01.geus.dk'
persistentId = 'doi:10.22008/FK2/****' 
api = NativeApi(dataverse_server,api_key)

#%% Exemple 1: getting list of files in dataset
dataset = api.get_dataset(persistentId)
files_DV_list = []

for file in dataset.json()['data']['latestVersion']['files']:
    if file["dataFile"]["filename"] !='height.tif':
        files_DV_list.append(file["directoryLabel"]+'/'+file["dataFile"]["filename"] )