spacepy icon indicating copy to clipboard operation
spacepy copied to clipboard

Can't control metadata order in JSON headed ASCII

Open evandegriff opened this issue 7 years ago • 5 comments

It would be nice to be able to order the JSON metadata when writing an ASCII file. You can specify the order of the data in toJSONheadedASCII, but writeJSONmetadata uses the same "order" of vars, and the metadata aren't vars so there's no way I can find to order the header.

evandegriff avatar Jul 27 '18 17:07 evandegriff

I can't promise this'll be a high priority item, but I'll put it on my list. What's your envisaged use case? The ordering of data columns is to allow consistent ordering and let folks use naive readers that required fixed column numbers. I'm not immediately seeing a clear use (other than "i'd really like to see time listed first in the metadata") of ordered metadata.

Any insight on what your use is would help with designing an implementation. Of course, a pull request with a candidate solution would also be welcomed!

drsteve avatar Jul 27 '18 19:07 drsteve

This comes from processing lanl geo into hourly/daily files. The copyright attr as the top of the file is nice, but doesn't seem to be possible in toJSONheadedASCII()

balarsen avatar Jul 27 '18 19:07 balarsen

Got it. I'll give it some thought.

drsteve avatar Jul 27 '18 19:07 drsteve

I am working on this one right now, I am finding a bit of a mess in datamodel.py with str, unicode, bytes etc, I will attempt to fix and add tests as needed.

balarsen avatar Jun 24 '19 17:06 balarsen

Another use case just came up, putting here for posterity.

I made a JSON headed ASCII file of the species resolved CREME96 worst 5-minutes. There are 92 species that are being put in the header in alphabetic order not Z order or the specified order, challenging as they bounce around between the header and column number.

balarsen avatar May 17 '21 22:05 balarsen