Skip to content

Commit cb3cd84

Browse files
input for fname
1 parent b04ec65 commit cb3cd84

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/goofi/nodes/outputs/writecsv.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ def config_input_slots():
1313
# This node will accept a table as its input.
1414
return {"table_input": DataType.TABLE,
1515
"start": DataType.ARRAY,
16-
"stop": DataType.ARRAY,}
16+
"stop": DataType.ARRAY,
17+
'fname': DataType.STRING}
1718

1819
@staticmethod
1920
def config_params():
@@ -38,12 +39,16 @@ def setup(self):
3839
self.last_values = {} # Store the last known value for each column
3940
self.is_writing = False
4041

41-
def process(self, table_input: Data, start: Data, stop: Data):
42+
def process(self, table_input: Data, start: Data, stop: Data, fname: Data):
4243
if start is not None and (start.data > 0).any() or self.params["Write"]["start"].value:
4344
self.is_writing = True
4445
self.start_time = time.time()
46+
if fname is not None:
47+
filename = fname.data
48+
else:
49+
# Use the filename from parameters if no custom filename is provided
50+
filename = self.params["Write"]["filename"].value
4551
# Generate a new filename each time writing starts
46-
filename = self.params["Write"]["filename"].value
4752
basename, ext = os.path.splitext(filename)
4853
datetime_str = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
4954
self.last_filename = f"{basename}_{datetime_str}{ext}"

0 commit comments

Comments
 (0)