# Reading open \*.sav file name to python environment

**URL:** <https://forum.itascainternational.com/t/reading-open-sav-file-name-to-python-environment/1853>\
**Category:** FLAC3D\
**Tags:** python\
**Created:** [December 16, 2024, 1:32pm UTC](https://forum.itascainternational.com/t/reading-open-sav-file-name-to-python-environment/1853 "2024-12-16T13:32:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![JuDi](https://avatars.discourse-cdn.com/v4/letter/j/7993a0/32.png) [@JuDi](https://forum.itascainternational.com/u/JuDi)\
**Post date:** [December 16, 2024, 1:32pm UTC](https://forum.itascainternational.com/t/reading-open-sav-file-name-to-python-environment/1853/1 "2024-12-16T13:32:18Z")

</div>

Hi, is there a way to read the current open \*.sav file via the itasca python module?  
I see only file.name() fish function in the manual so far.  
Thanks,  
Julia

---

<div class="post-metadata">

**Author:** ![msepu](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@msepu](https://forum.itascainternational.com/u/msepu)\
**Post date:** [December 16, 2024, 11:49pm UTC](https://forum.itascainternational.com/t/reading-open-sav-file-name-to-python-environment/1853/2 "2024-12-16T23:49:23Z")

</div>

i do not know if i understood your question properly, but here is how i restore sav files using python:

import os  
import itasca as it  
it.command(‘python-reset-state false’)

save\_file = ‘filename’  
it.fish.set(‘save\_name’,save\_file)  
it.command(“model rest @save\_name”)

---

<div class="post-metadata">

**Author:** ![paul](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.itascainternational.com/paul/32/196_2.png) [@paul](https://forum.itascainternational.com/u/paul)\
**Post date:** [December 17, 2024, 7:48am UTC](https://forum.itascainternational.com/t/reading-open-sav-file-name-to-python-environment/1853/3 "2024-12-17T07:48:49Z")

</div>

@JuDi great question. Would be very useful for me!

@msepu thanks! I’ll check it out today 🙂

---

<div class="post-metadata">

**Author:** ![JuDi](https://avatars.discourse-cdn.com/v4/letter/j/7993a0/32.png) [@JuDi](https://forum.itascainternational.com/u/JuDi)\
**Post date:** [December 17, 2024, 8:19am UTC](https://forum.itascainternational.com/t/reading-open-sav-file-name-to-python-environment/1853/4 "2024-12-17T08:19:53Z")

</div>

@msepu thanks. sorry for not posting clear.  
I have a sav file open. I open a python script and want to read the name of the open sav file automatically. something like  
it.fish.get(filename)  
which I then use in the labeling of an output plot produced in python.

---

<div class="post-metadata">

**Author:** ![markus](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.itascainternational.com/markus/32/288_2.png) [@markus](https://forum.itascainternational.com/u/markus)\
**Post date:** [December 17, 2024, 9:56am UTC](https://forum.itascainternational.com/t/reading-open-sav-file-name-to-python-environment/1853/5 "2024-12-17T09:56:49Z")

</div>

You could also include opening the save file within your python script. This way you have the filename available in python, since you already used it (e.g. as a function argument) to restore the save-file.

---

<div class="post-metadata">

**Author:** ![msepu](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@msepu](https://forum.itascainternational.com/u/msepu)\
**Post date:** [December 17, 2024, 12:26pm UTC](https://forum.itascainternational.com/t/reading-open-sav-file-name-to-python-environment/1853/6 "2024-12-17T12:26:21Z")

</div>

what i found in the documentation is something you must set in your sav when creating it, and that is the project title. please see:

[https://docs.itascacg.com/itasca920/common/kernel/doc/manual/global\_manual/global\_fish/global\_utilities/fish\_global.title.html#global.title](https://docs.itascacg.com/itasca920/common/kernel/doc/manual/global_manual/global_fish/global_utilities/fish_global.title.html#global.title)

---

<div class="post-metadata">

**Author:** ![Theophile](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.itascainternational.com/theophile/32/299_2.png) [@Theophile](https://forum.itascainternational.com/u/Theophile)\
**Post date:** [December 17, 2024, 12:43pm UTC](https://forum.itascainternational.com/t/reading-open-sav-file-name-to-python-environment/1853/7 "2024-12-17T12:43:00Z")

</div>

I would completely agree with this solution: set up a Python variable `filename="path/to/sav"` then execute the Python command `it.command(f'model restore {filename}')`.

Note that any Python data will be lost once the sav file is resotred. If you want to keep your Python state active, just execute the following FLAC3D command `python-reset-state false`.

---

<div class="post-metadata">

**Author:** ![JuDi](https://avatars.discourse-cdn.com/v4/letter/j/7993a0/32.png) [@JuDi](https://forum.itascainternational.com/u/JuDi)\
**Post date:** [December 18, 2024, 8:07am UTC](https://forum.itascainternational.com/t/reading-open-sav-file-name-to-python-environment/1853/8 "2024-12-18T08:07:12Z")

</div>

Thank you every one for the good suggestions.
