Implement class-based readers/writers #176
Labels
complex
This issue is a complex one that might require some thought
enhancement
New feature or request
umbrella
Issue made of other issues
Milestone
Problem
Currently, each reader/writer need to read the header, extract the information it needs from there, and then read the data - and in the future, validate it (see #14). That is a lot of repetition of the same code when each reader/writer should only worry about the actual read/write of the data. It also makes harder to implement common functionality across all readers/writers, should it be necessary, as the code would need to be updated in multiple places.
Solution
Move to class-based readers where all the common functionality can be packed together in a base class and where each reader/writer only needs to implement the specific reading action.
It could look something like the following, sticking the whole reading process in one go in the
__init__
method, as if it were a function:And similar for the writers. This has the advantage that the same file object is used for both the header and the data, as suggested in #28 . Actually adding validation is a task for #14 .
Addressing this PR will require multiple issues - and multiple PR - so convert the following in issues as needed:
Readers
lists
dicts
numpy
arrayspandas
dataframespolars
dataframesiterators
Writers
This should be compatible with the existing
Writer
class, which will need updating.lists
dicts
numpy
arrayspandas
dataframespolars
dataframesAs the class-based readers are implemented, the existing functions should be replaced and include a deprecation warning. Eg:
So we keep the same API, but internally we use the class-based approach.
The text was updated successfully, but these errors were encountered: