openfoamtutorials / OpenFOAM_Tutorials_

OpenFOAM Tutorials!
344 stars 230 forks source link

plot_forces.py not working #4

Open meouda opened 6 years ago

meouda commented 6 years ago

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.

meouda commented 6 years ago

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.