My goal was to have an easily re-usable setup for any number of of fixed width layouts. The code you've outlined above seems a bit more verbose than my setup, and is also more brittle when it comes to any changes to the layout, especially if columns get added anywhere but at the end of the file; you'll need to update the slices for each subsequent column.
Many of the fixed width files I typically work with have headers and footers that don't resemble the rest of the file and aren't as useful, so the skiprows and skipfooter options for my package will skip n rows at the top or bottom of the file (respectively), but still properly return the header like a petl Table would.
It's totally true that you could just re-implement the methods I have to accomplish all of this, but that's the point of sharing packages, right :)
Since this only solves for reading fixed width files (and not writing), I didn’t consider it ready for a PR for petlx or petl, which is the only reason it’s separate, honestly. Do you disagree?
--
You received this message because you are subscribed to the Google Groups "python-etl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-etl+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Many of the fixed width files I typically work with have headers and footers that don't resemble the rest of the file and aren't as useful, so the skiprows and skipfooter options for my package will skip n rows at the top or bottom of the file (respectively), but still properly return the header like a petl Table would.
I would absolutely be keen for a fixed width loader (and possibly saver) to be included into petl core.
We currently have skip() – how does skiprows() differ?
this case is obviously easy to do with len and rowslice.
what criteria should be used to when deciding if something should just be handled on your own vs incorporated into petl. The contribution docs don’t seem to have any overall guideline for this, but the overall philosophy seems to be very Zen of Python-ic, which I really like.
Here's a full out/in example: fixed_width_io.ipynbI believe that your header/footer on output could be addressed with petl.totext(prologue='...', epilogue='...')
--
You received this message because you are subscribed to a topic in the Google Groups "python-etl" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-etl/y81jlUx59TU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python-etl+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "python-etl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-etl+...@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to python-etl+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
----Joseph T. Bradley
You received this message because you are subscribed to the Google Groups "python-etl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-etl+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "python-etl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-etl+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I looked at adding support for negative values to head and tail, however both of those functions currently produce a table, whereas the functionality I have should produce an iterator. Perhaps it would make more sense to modify skip to both support negative values and to accept an include_header parameter which would apply skip only to the data rows? To skip both header and footer rows you would just chain skip functions.
Awesome! Yes, for the fixed width files I work with (fairly often), the header contains data that is not in the same format as the rest of the file, so I just provide a header, but want to skip the first line of the actual file.
I looked at adding support for negative values to head and tail, however both of those functions currently produce a table, whereas the functionality I have should produce an iterator. Perhaps it would make more sense to modify skip to both support negative values and to accept an include_header parameter which would apply skip only to the data rows? To skip both header and footer rows you would just chain skip functions.
Exactly.
--
You received this message because you are subscribed to the Google Groups "python-etl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-etl+...@googlegroups.com.
Exactly.
--
You received this message because you are subscribed to the Google Groups "python-etl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-etl+...@googlegroups.com.