# Report data to CSV without formatting

**URL:** <https://forum.inductiveautomation.com/t/report-data-to-csv-without-formatting/11532>\
**Category:** Ignition\
**Created:** [April 19, 2016, 6:25am UTC](https://forum.inductiveautomation.com/t/report-data-to-csv-without-formatting/11532 "2016-04-19T06:25:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Weffrey](https://avatars.discourse-cdn.com/v4/letter/w/6a8cbe/32.png) [@Weffrey](https://forum.inductiveautomation.com/u/Weffrey)\
**Post date:** [April 19, 2016, 6:25am UTC](https://forum.inductiveautomation.com/t/report-data-to-csv-without-formatting/11532/1 "2016-04-19T06:25:02Z")

</div>

Is there a way to run a report just to get the dataset and send it to an FTP server, without having to format a report?

I like the reporting format, but many of the reports that I would like to make are simply SQL queries that would be FTPed to a server and stored as CSV files. My problem is that if I try to make a traditional report and do this using the table component, some of my datasets have 40+ rows and this seems to make the table component very cumbersome. In fact it seems to start to slow down on me at around 25 columns.

I am only using the table component because I don’t know how else to get the dataset from the query to spit out into a CSV file via the report’s scheduling mechanism.

Thanks!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 19, 2016, 12:11pm UTC](https://forum.inductiveautomation.com/t/report-data-to-csv-without-formatting/11532/2 "2016-04-19T12:11:41Z")

</div>

Sounds like a job for a gateway event script, not a report. Scripts can retrieve the data (e.g. [system.db.runPrepQuery()](https://docs.inductiveautomation.com/display/DOC/system.db.runPrepQuery)), obtain the [CSV](https://docs.inductiveautomation.com/display/DOC/system.dataset.exportCSV) from the dataset, and [send an email](https://docs.inductiveautomation.com/display/DOC/system.net.sendEmail).

---

<div class="post-metadata">

**Author:** ![Weffrey](https://avatars.discourse-cdn.com/v4/letter/w/6a8cbe/32.png) [@Weffrey](https://forum.inductiveautomation.com/u/Weffrey)\
**Post date:** [April 19, 2016, 3:58pm UTC](https://forum.inductiveautomation.com/t/report-data-to-csv-without-formatting/11532/3 "2016-04-19T15:58:53Z")

</div>

I actually have it running as a gateway event script right now and emailing. Then I found out the end users wanted it FTP’d to their site. I knew the reports could FTP fairly easily but could not find a way to do it in scripting.

The report interface is very nice in that it also keeps a very organized and visual record of reports, which i would consider this one of. So I like having it get the data but am just not sure how to send it to a FTP server as a CSV without using the table component.

So I am blocked - scripting with no FTP or report module where I can’t get the data out. Kind of ironic. 😒

---

<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:** [April 19, 2016, 5:32pm UTC](https://forum.inductiveautomation.com/t/report-data-to-csv-without-formatting/11532/4 "2016-04-19T17:32:13Z")

</div>

If you’re running in 7.8 and emailing the report successfully, you should be able to FTP it also. Check out [system.report.executeAndDistribute](https://docs.inductiveautomation.com:8443/display/DOC/system.report.executeAndDistribute) – ftp is the fourth action setting listed, and the next to last code snippet is an example of using it.

If you’re emailing it without being in a report, then you’ll need a Jython solution for FTP. I know there’s libraries out there, but they aren’t coming to mind at the moment.  
[edit]  
Whaddya know, they’re built in. [jython.org/docs/library/ftplib.html](http://www.jython.org/docs/library/ftplib.html)
