Skip to content

Commit ff7c0ba

Browse files
changes in the guess_second_key function
1 parent 060cbc5 commit ff7c0ba

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

src/ansys/dpf/core/data_sources.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,39 @@ def guess_result_key(filepath: str) -> str:
221221

222222
@staticmethod
223223
def guess_second_key(filepath: str) -> str:
224-
"""For files with an h5 or cff extension, look for another extension."""
224+
"""For files with an h5 or cff extension, look for another extension.
225+
226+
Parameters
227+
----------
228+
filepath
229+
Path to the file.
230+
231+
Returns
232+
-------
233+
str
234+
First extension key name
235+
236+
Examples
237+
--------
238+
Find the first extension key of a result file with multiple extensions keys
239+
240+
>>> from ansys.dpf import core as dpf
241+
>>> from ansys.dpf.core import examples
242+
>>>
243+
>>> # Download the result files
244+
>>> paths = examples.download_fluent_axial_comp()
245+
>>> # Create the DataSources object
246+
>>> my_data_sources = dpf.DataSources()
247+
>>> # Define the extension key for the file in the given path
248+
>>> # We see that the paths are given in a dictionary.
249+
>>> # So to choose the correct file you need to give as an argument:
250+
>>> # - the list label
251+
>>> # - the file index in that list
252+
>>> my_file_key = my_data_sources.guess_second_key(filepath=paths["cas"][0])
253+
>>> print(my_file_key)
254+
cas
255+
256+
"""
225257
accepted = ["cas", "dat"]
226258
without_ext = os.path.splitext(filepath)[0]
227259
new_split = os.path.splitext(without_ext)

0 commit comments

Comments
 (0)