nd2reader icon indicating copy to clipboard operation
nd2reader copied to clipboard

Is it possible to read from a io.BytesIO or io.StringIO or just accepts filename?

Open WaterKnight1998 opened this issue 5 years ago • 2 comments

I am using this reader in a flask API.

I would like to be able to use this reader with a io.BytesIO or io.StringIO so there is no need to create a temporal file in the system.

WaterKnight1998 avatar Jun 04 '20 10:06 WaterKnight1998

Hi thanks for your question. There is no fundamental reason why this would not be possible, however as it stands, it is not implemented. The relevant code is in reader.py: https://github.com/rbnvrw/nd2reader/blob/492d0ec68d21e55e63aa2914f63edc8e0ace74fa/nd2reader/reader.py#L25

The Reader class expects a filename and uses open() to get a file object. I think if you would use io.BytesIO instead it would be a drop-in replacement (apart from some small changes in the code where a filename is expected).

Please let me know if you're interested in submitting a PR, otherwise it might take a little bit longer to add this feature.

rbnvrw avatar Jun 06 '20 16:06 rbnvrw

Please let me know if you're interested in submitting a PR, otherwise it might take a little bit longer to add this feature.

@rbnvrw I am interested. However, maybe I need some, in tha case I will ask you here

WaterKnight1998 avatar Jun 06 '20 17:06 WaterKnight1998