Skip to content

Read multiple datasets with one call to cfdm.read #336

@davidhassell

Description

@davidhassell

It would be nice to be able to read multiple datasets in one cfdm.read call, eith as a list, a list implied by globbing, or anything in a directory, possibly including its subdirectories:

>>> f = cfdm.read(['file1.nc', 'file2.nc'])  # list
>>> f
[<Field: specific_humidity(latitude(5), longitude(8)) 1>,
 <Field: air_temperature(height(1), grid_latitude(10), grid_longitude(9)) K>]
>>> f = cfdm.read('file[12].nc')  # glob
>>> f
[<Field: specific_humidity(latitude(5), longitude(8)) 1>,
 <Field: air_temperature(height(1), grid_latitude(10), grid_longitude(9)) K>]
>>> f = cfdm.read('~/directory/', recursive=True, followlinks=True)  # directories
>>> f
[<Field: specific_humidity(latitude(5), longitude(8)) 1>,
 <Field: air_temperature(height(1), grid_latitude(10), grid_longitude(9)) K>]

This is exactly how cf-python does things.

Metadata

Metadata

Assignees

No one assigned

    Labels

    dataset readRelating to reading datasetsenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions