NCAS-CMS / NCAS-CMS/cf-python

Read file-like object datasets

Open
#937 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

dataset read enhancement
Dominant language
Python
Stars
150
Forks
23
Avg merge
1d 11h
Merged PRs (30d)
2

Description

It would be very nice to be able to read datasets defined by an open file handle with cfdm.read.

>>> import fsspec
>>> fs = fsspec.filesystem(...)
>>> fh = fs.open('filename.nc', 'rb')
>>> f = cf.read(fh)

This particular example would be equivalent to:

>>> f = cf.read('filename.nc', filesystem=fs)

E.g. for a local file, this should also work:

>>> fh = open('filename.nc', 'rb')
>>> f = cf.read(fh)

This will be largely implemented via https://github.com/NCAS-CMS/cfdm/issues/401

PR to follow.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the cf.read entry point and read the referenced cfdm issue #401, which is expected to provide most of the implementation. Check how an open local or fsspec file handle is accepted and identify the existing read-related tests before making changes. Done means cf.read accepts both kinds of file-like object as shown without breaking path-based reads.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.