Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import time histories with number of points not multiple of 6 raise error #29

Closed
mglesser opened this issue May 7, 2020 · 4 comments
Closed

Comments

@mglesser
Copy link

mglesser commented May 7, 2020

.uff files of time histories with number of points that is not a multiple of 6, have a last line with 1 to 5 values only for each dataset. When trying to read such a file an error is raised at line 1367 of pyuff.py. It is caused by "float" trying to convert an empty string to float.

A quick (but potentially ugly, I'm far from a Python expert) fix is to replace line 1367 by:

for i in range(len(line) // 13):  
    if (line[13 * i:13 * (i + 1)] != '             '):  
        values.extend([float(line[13 * i:13 * (i + 1)])])
@jankoslavic
Copy link
Contributor

DEar Martin!

Could you please provide also a test file, so it can be added to tests?
REgards,
Janko

@mglesser
Copy link
Author

Dear Janko,
Please find below a .uff file that can be used to reproduce the issue. I took a better look to the file and it seems that the issue comes from the fact that the software used to generate the .uff filled the last non-full data line with white spaces.
Best regards,
Martin

time-history.zip

@jankoslavic
Copy link
Contributor

Dear Martin! I implemented a slightly numerically better implementation:

                    for line in split_data[:-1]:  # '6E13.5'
                        values.extend([float(line[13 * i:13 * (i + 1)]) for i in range(len(line) // 13)])
                    else:
                        line = split_data[-1]
                        values.extend([float(line[13 * i:13 * (i + 1)]) for i in range(len(line) // 13) if line[13 * i:13 * (i + 1)]!='             '])

it is on pypi. please upgrade

@mglesser
Copy link
Author

Thanks a lot, Janko

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants