Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added data/dataset58b_with_wrong_CRLF_before-1.uff
Binary file not shown.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "pyuff"
version = "2.5.0"
version = "2.5.1"
authors = [{name = "Primož Čermelj, Janko Slavič", email = "janko.slavic@fs.uni-lj.si"}]
maintainers = [{name = "Janko Slavič et al.", email = "janko.slavic@fs.uni-lj.si"}]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion pyuff/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "2.5.0"
__version__ = "2.5.1"
from .pyuff import *
from .datasets import *

10 changes: 6 additions & 4 deletions pyuff/datasets/dataset_58.py
Original file line number Diff line number Diff line change
Expand Up @@ -1090,11 +1090,13 @@ def _extract58(block_data, header_only=False):
else:
bo = '>'
if (dset['ord_data_type'] == 2) or (dset['ord_data_type'] == 5):
# single precision - 4 bytes
values = np.asarray(struct.unpack('%c%sf' % (bo, int(len(split_data) / 4)), split_data), 'd')
# single precision - 4 bytes, note: sometimes split_data wrongly contains CR/LF and
# therefore the length of split_data is not divisible by 4
values = np.asarray(struct.unpack('%c%sf' % (bo, int(len(split_data) / 4)), split_data[:(len(split_data) // 4)*4]), 'd')
else:
# double precision - 8 bytes
values = np.asarray(struct.unpack('%c%sd' % (bo, int(len(split_data) / 8)), split_data), 'd')
# double precision - 8 bytes, note: sometimes split_data wrongly contains CR/LF and
# therefore the length of split_data is not divisible by 8
values = np.asarray(struct.unpack('%c%sd' % (bo, int(len(split_data) / 8)), split_data[:(len(split_data) // 8)*8]), 'd')
except:
raise Exception('Potentially wrong data format (common with binary files from some commercial softwares). Try using pyuff.fix_58b() to fix your file. For more information, see https://github.com/ladisk/pyuff/issues/61')
else:
Expand Down