Support table metadata in io.ascii#683
Conversation
|
yep, that would be great. But I think its important that we keep at least the |
|
Attached is an initial effort at an ASCII file format that fully preserves a For a quick look at this in action see: http://nbviewer.ipython.org/4742168/ |
|
Are you thinking this should be the default ascii output? That is, this comes out when I do ``tab.write(format='ascii')? I can see the virtue of the default having all the metadata, but it might be good to have a 'plainascii' format or something like that which preserves the current (simpler) output. I've found that useful for tables where the person I'm sending it to might not know what to do with even a JSON-like header. It would also be nice to have the That might be best treated as a separate PR, but that's contingent on whether or not the 'plain' version remains. |
|
@eteq - I was not planning to have this new format be the default output just because it has so much cruft (if you don't care about fully storing a table). I think most people (both of us included) will prefer the simple output as the default and be able to choose Your second suggestion is definitely worth discussion, in a separate PR as you say. |
|
Just a thought - why not simply define a format |
|
@astrofrog - The point is to stay within the confines of the "ASCII table" format, which is (for these purposes) a row-oriented, character-delimited, human-readable table. The big benefit of writing a table out in this way is that it will still be readable by every other CSV-style reader, like There is certainly nothing wrong with making a JSON reader/writer as well, but that would live in its own package separate from I struggled with the name and I'm open for suggestions. I was thinking about the Ascii representation of a Table, which gets you to |
|
@taldcroft - I see what you mean. By the way, could you register this format with the I/O registry? |
|
hmm, so that means there will be both an 'ascii' format and an 'asciitable' format? I think that will be very confusing... what about |
|
|
|
Thanks for the feedback, which has given me a new idea that I think is much better. Instead of having an entirely new
This could of course support additional or user-specified meta formats. The default could be set as a configuration item so if @eteq always wants to see units, then he can. These meta formats will get used in the reading process, thereby allowing a configurable degree of round-tripping. This also allows an easy way to create data files by hand with limited metadata already included. The guessing process within Because this now uses a new option, then all the I try hard to avoid new kwargs in One slight wart - in order to make detection of these meta formats reliable, I would want to use some sort of start / stop markers in the header. It should be easy enough that people can create it by hand but unambiguous. Another issue - in some cases there is redundant information, for instance where the column names are encoded both in the meta data and in the table itself (e.g. as the first uncommented line in the default format). This can lead to conflicts that need to be resolved. |
|
I like your new idea @taldcroft - a few comments on it: I share your wish to not add new Can't the stop/start markers just be the beginning and ned of the first comment block or something? (Or say that if you want additional comments, you have to add a special start/stop marker?) And I think redundant info is ok if you have the reader just fail if there's a conflict. I think that's the right thing to do rather than try to guess at how the user wants it resolved. |
|
Overtaken by APE6 and #2319. |
This is an initial feature request to more fully support table metadata in
io.ascii. This was discussed in #664 and #659.This issue is meant to address just reading and writing metadata into an ASCII-formatted table.
There is the related issue of providing a framework for manipulating metadata beyond the current concept of a simple ordered dict. This has a much larger scope and potentially touches
nddata,io.fitsand others.cc: @kbarbary