valueLabels property of header does not preserve order of labels

Issue #49 new
Former user created an issue

For the project I want to use savReaderWriter for, the order of the labels returned by valueLabels matters. Because savReaderWriter returns them as a dictionary, the order is lost. I have been able to modify the source of header.py in my local copy to use collections.OrderedDict instead (including changing decode() to use OrderedDictwhen original dict is OrderedDict). However surely I'm not the only one this matters to?

Incidentally the decode process also seems to convert codes from floats to Unicode strings as well.

Comments (1)

  1. Albert-Jan Roskam repo owner

    Hi,

    Sorry for my slow reply. I have created savReaderWriter several years ago now, and nobody had made this request before now. But now, almost in the same week, two people asked for it.:-) I thought you were one of my colleagues and I had already replied to him. Yep, changing it so the valueLabels property returns an OrderedDict is easy enough. I will do that. Re: the decode function: so you're saying that, ioUtf8=True, value_labels = {1.0: b"apple", 2.0: b"pear"} becomes value_labels = {u"1.0": u"apple", u"2.0": u"pear"}? What Python version are you using?

  2. Log in to comment