I wanted to bounce ideas off you guys and I don't know if there is way to do this in ignition but I have a script that opens certain files from a folder if clicked on a cell, but the postfix of the folder is in format _XXXXXXX. My problem is I have no way of knowing the postfix, the closest way I can separate the folders is the "Date Modified" filter in Windows file explorer which corresponds to a DAte/Time column I have in power table.
In short there are two rows in power table with seria number a, but I want to open files from the first folder from cells in one row and files from the second folder from cells in the other row. And I have info about the date and time to when each folder was created in the power table.
Any help or suggestion is appreciated. Thanks.
import os
import system
if colName not in ["Serial Number", "Result"]:
return
serial = self.data.getValueAt(rowIndex, self.data.getColumnIndex("Serial Number"))
location = self.data.getValueAt(rowIndex, self.data.getColumnIndex("Test Stand"))
folder_path = "A:\\Result\\M54\\Test\\AT\\" + location + "\\" + serial + "\\" + serial + "_XXXXXXXX"
# Function to find the first file in the specified folder
ext = ""
if colName == "Serial Number":
ext = ".html"
elif colName == "Result":
ext = ".txt"
def find_file(folder_path, ext):
for file_name in os.listdir(folder_path):
if file_name.endswith(ext):
return os.path.join(folder_path, file_name)
return None
# Find the HTML file
file_path = find_file(folder_path, ext)
print("File path:", file_path)
# Open the file using system.net.openURL
if file_path:
try:
system.net.openURL("file:///" + file_path.replace("\\", "/"))
except Exception as e:
system.gui.errorBox("Failed to open file: {}".format(str(e)))
else:
system.gui.warningBox("No file found in the specified folder.")