# Saving "Reporting" document save as CSV file and automatically to a specific folder?

**URL:** <https://forum.inductiveautomation.com/t/saving-reporting-document-save-as-csv-file-and-automatically-to-a-specific-folder/46467>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [May 7, 2021, 8:00am UTC](https://forum.inductiveautomation.com/t/saving-reporting-document-save-as-csv-file-and-automatically-to-a-specific-folder/46467 "2021-05-07T08:00:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![trishadx](https://avatars.discourse-cdn.com/v4/letter/t/eb9ed0/32.png) [@trishadx](https://forum.inductiveautomation.com/u/trishadx)\
**Post date:** [May 7, 2021, 8:00am UTC](https://forum.inductiveautomation.com/t/saving-reporting-document-save-as-csv-file-and-automatically-to-a-specific-folder/46467/1 "2021-05-07T08:00:15Z")

</div>

Hi all,  
I’ve made use of the reporting module on ignition 8.1. At the moment I’m opening up vision and right clicking to save it as a PDF and locating the folder myself.

I’m wondering would it be possible to set up scheduled reporting which saves to a specific folder?  
Also, looking at a previos thread, would this code still work to convert the data to appear as a CSV file?

```auto
csvBytes = system.report.executeReport(path="My Path", project="MyProject", parameters={}, fileType="csv")

```

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [May 7, 2021, 10:22am UTC](https://forum.inductiveautomation.com/t/saving-reporting-document-save-as-csv-file-and-automatically-to-a-specific-folder/46467/2 "2021-05-07T10:22:29Z")

</div>

According to the [documentation](https://docs.inductiveautomation.com/display/DOC81/system.report.executeReport), yes. Just keep in mind that this only gives you the bytes. You will still need to do something with them.

[system.report.executeAndDistribute()](https://docs.inductiveautomation.com/display/DOC81/system.report.executeAndDistribute) can also save the file for you in one go.

For both options, remember that the gateway needs access to the file path.

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [May 7, 2021, 1:48pm UTC](https://forum.inductiveautomation.com/t/saving-reporting-document-save-as-csv-file-and-automatically-to-a-specific-folder/46467/3 "2021-05-07T13:48:14Z")

</div>

Remember when you use system.report.\* functions, you need to trigger the execution somehow. If you want that automated, you can use a timer script, a tag change script, or, as of 8.1.6, the new scheduled script which lets you set up custom execution schedules.

However, there’s also a [built in scheduled execution](https://docs.inductiveautomation.com/display/DOC81/Report+Schedules) for reports. This can save to a folder you specify, and that folder and file name can even be dynamic. Check out [the docs](https://docs.inductiveautomation.com/display/DOC81/Scheduling+Actions#SchedulingActions-SaveFileAction) for an example of how to do this.

---

<div class="post-metadata">

**Author:** ![flavien](https://avatars.discourse-cdn.com/v4/letter/f/f475e1/32.png) [@flavien](https://forum.inductiveautomation.com/u/flavien)\
**Post date:** [December 8, 2022, 3:41pm UTC](https://forum.inductiveautomation.com/t/saving-reporting-document-save-as-csv-file-and-automatically-to-a-specific-folder/46467/4 "2022-12-08T15:41:53Z")

</div>

Is it possible to email and save a report with one execution in a Run Script Action ?

For now I use system.report.executeReport() to email it then system.report.executeAndDistribute() to save it to my mounted folder.  
For me, this way execute the report twice. I would like to execute once for all to improve performance.

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [December 8, 2022, 4:00pm UTC](https://forum.inductiveautomation.com/t/saving-reporting-document-save-as-csv-file-and-automatically-to-a-specific-folder/46467/5 "2022-12-08T16:00:34Z")

</div>

Sounds like what we need is a way to use `system.file.writeFile()` to write binary data. Then you could write the bytes you receive from executeReport(). I'll make a feature request for this. [IGN-6904]

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [December 14, 2022, 6:50pm UTC](https://forum.inductiveautomation.com/t/saving-reporting-document-save-as-csv-file-and-automatically-to-a-specific-folder/46467/6 "2022-12-14T18:50:59Z")

</div>

Well it would sure help if I could correct read our own documentation. 🤦‍♀️

[system.file.writeFile()](https://docs.inductiveautomation.com/display/DOC81/system.file.writeFile) does in fact accept binary data. So use executeReport() once, then use the bytes returned for both your email and your file save.
