wepy icon indicating copy to clipboard operation
wepy copied to clipboard

HDF5 file reading error

Open ndonyapour opened this issue 3 years ago • 5 comments

Hello,

I recently installed wepy from pip. I had some issues when I tried to run my simulations so I updated h5py and networkx. I ran into "Type names and field names must be valid identifiers" error when I read from my HDF5 reporter file. I would appreciate it if you could help me out.

Thank you!

ndonyapour avatar Oct 19 '22 22:10 ndonyapour

You'll have to give me which versions you have installed of all of that and the full stack trace. Also clarify exactly the process you followed. Are you reading the HDF5 data from a different version than you wrote with etc.

salotz avatar Oct 20 '22 01:10 salotz

Thank you for being so helpful. I had a discrepancy in the version of h5py. The HDF5 file was written with version 2.10, and I've been reading the data with version 3.10.

ndonyapour avatar Oct 20 '22 21:10 ndonyapour

There are compatibility problems with reading >=3 with things written in version 2, so I would try to read with <3 if you can.

salotz avatar Oct 25 '22 23:10 salotz

Following up on this, since I was about to post a separate issue. For anyone else who is interested, here are some more details:

Raises a ValueError: Type names and field names must be valid identifiers: "b'decision_id'"

Minimal code needed to reproduce:

we = WepyHDF5(h5name,'r')
we.open()
we.resampling_records([0])

It can also be observed with:

print(we.record_fields)

where byte strings are shown using the "b" character before string.

We can fix this in HDF5=3.10 by using the .asstr() function when reading the record fields.

alexrd avatar Mar 31 '23 17:03 alexrd

depends on #78

salotz avatar Aug 31 '23 02:08 salotz