Search code examples
pythonfile-iooutput-directory

Is it possible to change save path of a file saved by an external library?


I use a library in python called pyansys in which I use a method called save_as_vtk.

There it is: documentation

This method generates a file for me and saves it to my working directory. I would like that file to be saved elsewhere... I don't want it moved because sometimes it is 20+ Gb and it would take too long.

Anybody has an idea?

Thank you!


Solution

  • I'm the maintainer of the pyansys package.

    This was answered in https://github.com/akaszynski/pyansys/issues/219

    Repeated here:

    It appears that ResultFile.save_as_vtk already has a filename parameter:

    def save_as_vtk(self, filename, rsets=None, result_types=['ENS']):
        """Writes results to a vtk readable file.
    
        The file extension will select the type of writer to use.
        ``'.vtk'`` will use the legacy writer, while ``'.vtu'`` will
        select the VTK XML writer.
    
        Parameters
        ----------
        filename : str
            Filename of grid to be written.  The file extension will
            select the type of writer to use.  ``'.vtk'`` will use the
            legacy writer, while ``'.vtu'`` will select the VTK XML
            writer.