DOI-USGS/sciencebasepy

get_item_file_info returns null

Closed this issue · 1 comments

The get_item_file_info() function returns a null value for sb items that have files attached. I have an active sciencebase session running. I would like to download specific files, not all files available so seeing this file info would be extremely useful.

sb=sciencebasepy.SbSession()
swbv1_c1=sb.find_items_by_title("Simulated daily net infiltration and irrigation amount datasets for Shellmound, Mississippi, 1915 to 2011")
file_info=sb.get_item_file_info(swbv1_c1)
len(file_info)

ennsk commented

@jtrost-usgs you're missing one step in there. The sb.find_items_by_title() method returns a list of items and their sb ids but not the actual item json needed for sb.get_item_file_info. Your code needs to use one more line of code ( with sb.get_item()). ex:

sb=sciencebasepy.SbSession()
swbv1_c1_query=sb.find_items_by_title("Simulated daily net infiltration and irrigation amount datasets for Shellmound, Mississippi, 1915 to 2011")
# This is the line of code you were missing
swbv1_c1 = sb.get_item(swbv1_c1_query['items'][0]['id'])
file_info=sb.get_item_file_info(swbv1_c1)
len(file_info)