[Nexus] Problem with demo example?

V. Armando Solé sole at esrf.fr
Thu Sep 28 09:26:06 BST 2017


Dear colleagues,

I think there is a problem with the BasicWriter.py example found at:

http://download.nexusformat.org/sphinx/examples/h5py/index.html

Unfortunately, that example is targeting Python 2.x and that can lead to
misunderstandings.

If I read the documentation, NX_CHAR fields should be UTF-8 encoded strings.

Running the example, all the attributes are read as bytes and not as
UTF-8 encoded strings when read under Python 3.

The worst thing is that if the example is run under Python 3 (just by
adding the missing parenthesis to the print statements), the generated
file is different because indeed, strings are strings and not bytes
without any encoding.

Please, clarify is NX_CHAR fields should correspond to UTF-8 encoded
strings or to byte strings.

The example should be fixed and all the attribute strings should have a
lower case U character prepended in order to:

- Comply with the documentation
- Generate same output under Python2 and Python3
- Generate same input under Python2 and Python3

Best regards,

Armando



More information about the NeXus mailing list