You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the sbdf class, on line 1888 there is the presumption that the sbdf_file provided is a string filename. One might like to use the function by passing in a io.BytesIO object to avoid having to create a file and then just read back the contents.
Can we update it to allow file-like objects be passed in in place of filenames?
For example, line 1888 in sbdf.pyx could reflect something like this:
# Open the SBDF file if necessary
if isinstance( sbdf_file, str ):
output_file = _pathlike_to_fileptr(sbdf_file, "wb")
else:
output_file = sbdf_file
The text was updated successfully, but these errors were encountered:
Hi, @jagrata! The reason the SBDF module behaves like this (i.e., working with paths instead of any Python io objects) is that the implementation is using a native C library for SBDF operations that uses the C standard-IO functions (fopen/fread/fwrite/et al), which have no easy way to extend to working with io objects. Any support would be almost exactly like what you described: using tempfile.NamedTemporaryFile to create a temp file, export the data to it with sbdf.export_data(), rewind the temp file, and read it into the io.BytesIO object. Directly updating the native library to have a level of abstraction to allow what you is looking for might also have the effect of impacting read/write performance (losing perf that was the primary reason for using the native library).
In the sbdf class, on line 1888 there is the presumption that the sbdf_file provided is a string filename. One might like to use the function by passing in a io.BytesIO object to avoid having to create a file and then just read back the contents.
Can we update it to allow file-like objects be passed in in place of filenames?
For example, line 1888 in sbdf.pyx could reflect something like this:
The text was updated successfully, but these errors were encountered: