# Automatic Printing/Export

**URL:** <https://forum.inductiveautomation.com/t/automatic-printing-export/7734>\
**Category:** Ignition\
**Created:** [December 19, 2013, 5:29pm UTC](https://forum.inductiveautomation.com/t/automatic-printing-export/7734 "2013-12-19T17:29:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dfenter](https://avatars.discourse-cdn.com/v4/letter/d/87869e/32.png) [@dfenter](https://forum.inductiveautomation.com/u/dfenter)\
**Post date:** [December 19, 2013, 5:29pm UTC](https://forum.inductiveautomation.com/t/automatic-printing-export/7734/1 "2013-12-19T17:29:55Z")

</div>

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?

Dan

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [December 19, 2013, 5:41pm UTC](https://forum.inductiveautomation.com/t/automatic-printing-export/7734/2 "2013-12-19T17:41:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dfenter](https://avatars.discourse-cdn.com/v4/letter/d/87869e/32.png) [@dfenter](https://forum.inductiveautomation.com/u/dfenter)\
**Post date:** [December 20, 2013, 3:05pm UTC](https://forum.inductiveautomation.com/t/automatic-printing-export/7734/3 "2013-12-20T15:05:37Z")

</div>

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

system.nav.openWindow(“Advanced/PQ\_2”)  
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?

Dan

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [December 20, 2013, 3:58pm UTC](https://forum.inductiveautomation.com/t/automatic-printing-export/7734/4 "2013-12-20T15:58:17Z")

</div>

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:

```auto
system.nav.openWindow("Advanced/PQ_2")
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)
```

---

<div class="post-metadata">

**Author:** ![Esmeralda\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@Esmeralda\_Lopez](https://forum.inductiveautomation.com/u/Esmeralda_Lopez)\
**Post date:** [August 8, 2022, 10:45pm UTC](https://forum.inductiveautomation.com/t/automatic-printing-export/7734/5 "2022-08-08T22:45:12Z")

</div>

and then will print automatically?

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [August 8, 2022, 11:17pm UTC](https://forum.inductiveautomation.com/t/automatic-printing-export/7734/6 "2022-08-08T23:17:47Z")

</div>

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.
