openfoamtutorials/OpenFOAM_Tutorials_

plot_forces.py not working

meouda opened this issue · 1 comments

Dear Sir,

Thanks for the great tutorial.

I am trying to plot the forces using the supplied python script (plot_forces.py) but it returns the following error:
Traceback (most recent call last):
File "./plot_forces.py", line 41, in
data_dict = line2dict(line)
File "./plot_forces.py", line 18, in line2dict
floats = [float(x) for x in tokens]
ValueError: invalid literal for float(): -2.6235e-13,0.0459128

So, what is the reason for this error? and which python version you are using?

Best regards.

Solved. For anyone facing the same problem add the following line:
line=line.replace(",", " ")
before:
tokens_unprocessed = line.split()

This is to avoid problems with the split() method because split()uses whitespace as default separator

Best regards.