Automatic Printing/Export

I need to setup a timer script to automatically print a window, and export a table to a CSV file. We typically have multiple clients open, so I was wondering if this would better setup as a gateway timer script.

My issue is that I can get the window to print without human interaction, but I have not been able to get it to export to CSV without human interaction. Is there a function like “showprintDialog” for the export to CSV function that eliminates the need to press OK?


You can use the system.dataset.toCSV function.

It returns a CSV string that you can write to a file using the system.file.writeFile function.

Here is the script I have written. I still have to have someone press ok to get it to export.

window = system.gui.getWindow(“Advanced/PQ_2”)
data = window.rootContainer.getComponent(“Table”).data
new = system.dataset.toCSV(data, 1, 0)
filename = system.file.saveFile(“PQ.CSV”)
if filename != None:
system.file.writeFile(filename, new)

What can I do to eliminate human interaction to automatically export the data to a CSV file?


Hi Dan,
Get rid of this line “filename = system.file.saveFile(“PQ.CSV”)”. You will have to know the file path to the file that you want to write.

Try this code:

window = system.gui.getWindow("Advanced/PQ_2")
data = window.rootContainer.getComponent("Table").data
new = system.dataset.toCSV(data, 1, 0)
filename = "your\file\path\PQ.CSV"
system.file.writeFile(filename, new)

and then will print automatically?

It looks like the samples posted were all saving to file, nothing related to printing. You may want to create a new post and state whether vision or perspective.