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

Having trouble with saving file as in-memory buffer #1439

Open
RadheChandu opened this issue Oct 10, 2023 · 0 comments
Open

Having trouble with saving file as in-memory buffer #1439

RadheChandu opened this issue Oct 10, 2023 · 0 comments

Comments

@RadheChandu
Copy link

Hello meshioTeam,

Thank you for making such a great product. I am working on a project wherein I need to work on openfoam results files. I need mesh file in '.mesh' format which I am converting using meshio. But I dont want to save a physical file, rather would like to use as in-memory buffer.

I am using the following code..
`points = Zoner.points
cells = [("hexahedron", [Zoner.cell_point_ids(i)])
for i in range(Zoner.n_cells)]

mesh = meshio.Mesh(points, cells)

import io

buffer = io.BytesIO()

mesh.write(buffer, file_format = 'gmsh')`

I am getting the following error.

`Traceback (most recent call last):

Input In [88] in <cell line: 11>
mesh.write(buffer, file_format = 'gmsh')

File ~\AppData\Roaming\Python\Python39\site-packages\meshio_mesh.py:241 in write
write(path_or_buf, self, file_format, **kwargs)

File ~\AppData\Roaming\Python\Python39\site-packages\meshio_helpers.py:188 in write
return writer(filename, mesh, **kwargs)

File ~\AppData\Roaming\Python\Python39\site-packages\meshio\gmsh\main.py:111 in
"gmsh": lambda f, m, **kwargs: write(f, m, "4.1", **kwargs),

File ~\AppData\Roaming\Python\Python39\site-packages\meshio\gmsh\main.py:102 in write
writer.write(filename, mesh, binary=binary, float_fmt=float_fmt)

File ~\AppData\Roaming\Python\Python39\site-packages\meshio\gmsh_gmsh41.py:313 in write
with open(filename, "wb") as fh:

TypeError: expected str, bytes or os.PathLike object, not BytesIO`

Can you please help me with this..

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

1 participant