# Loading vtkMRMLTextNode with arbitrary file name extension

**URL:** <https://discourse.slicer.org/t/loading-vtkmrmltextnode-with-arbitrary-file-name-extension/29747>\
**Category:** Development\
**Created:** [May 31, 2023, 9:48am UTC](https://discourse.slicer.org/t/loading-vtkmrmltextnode-with-arbitrary-file-name-extension/29747 "2023-05-31T09:48:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![benzwick](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/benzwick/32/80521_2.png) [@benzwick](https://discourse.slicer.org/u/benzwick)\
**Post date:** [May 31, 2023, 9:48am UTC](https://discourse.slicer.org/t/loading-vtkmrmltextnode-with-arbitrary-file-name-extension/29747/1 "2023-05-31T09:48:01Z")

</div>

Is it possible to load a [vtkMRMLTextNode](https://apidocs.slicer.org/main/classvtkMRMLTextNode.html) with a file extension other than txt, xml or json? For example, I want to load a text file with the extension “.inp” but Slicer only shows the option to load it as a volume.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [May 31, 2023, 1:55pm UTC](https://discourse.slicer.org/t/loading-vtkmrmltextnode-with-arbitrary-file-name-extension/29747/2 "2023-05-31T13:55:22Z")

</div>

Allowing a reader to accept arbitrary file extension leads to user confusion, so I would try to avoid doing that. Fortunately, it is not needed anymore because it is really easy to create a scripted reader for any file format.

You can add a few ten lines of Python script to any of your Python scripted modules that specify that the module can read of .inp files. When the user tries to open such a file then the reader can inspect the file (e.g., read the first few lines of the file to see if is indeed a file it can handle) and then offer it for reading. You can similarly specify a writer plugin. [See complete examples here](https://github.com/Slicer/Slicer/blob/main/Applications/SlicerApp/Testing/Python/SlicerScriptedFileReaderWriterTest.py).

---

<div class="post-metadata">

**Author:** ![benzwick](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/benzwick/32/80521_2.png) [@benzwick](https://discourse.slicer.org/u/benzwick)\
**Post date:** [May 31, 2023, 2:37pm UTC](https://discourse.slicer.org/t/loading-vtkmrmltextnode-with-arbitrary-file-name-extension/29747/3 "2023-05-31T14:37:09Z")

</div>

That’s perfect! I thought this was only possible using C++.
