VoxLight / fixedwidthpy

Fixed Width Files are a NIGHTMARE!!... So, I took my time to make the BEST library for dealing with them!
Apache License 2.0
1 stars 1 forks source link

move .fetch_data into FWF handler or the DataRow constructor maybe? #4

Open VoxLight opened 3 weeks ago

VoxLight commented 3 weeks ago

The syntax the library currently uses is a little gross, we always call .fetch_data when we create the data row. This might allow us to more easily implement configs if we just want to make stencil DataRows and not fill them with any data, but even then you would need to fetch_data to get the column formatting.

Basically, we just need something to help make this syntax nicer:

# Create the header record and get the data for it.
header_record = HeaderRecord()
header_record.fetch_data()
VoxLight commented 3 weeks ago

.fetch_data could return the instance, instead of the data row. We can still go grab the data if we want it, but having fetch_data return the instance allows us to move it all onto one line? We could also have a flag in the constructor for if we want to init_with_data and call fetch_data inside the constructor. This means it's more flexible and can conform to the different needs.