# Data request for CSV file

**URL:** <https://forum.inductiveautomation.com/t/data-request-for-csv-file/111067>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [September 29, 2025, 4:55pm UTC](https://forum.inductiveautomation.com/t/data-request-for-csv-file/111067 "2025-09-29T16:55:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bruno\_Burgin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bruno_burgin/32/80141_2.png) [@Bruno\_Burgin](https://forum.inductiveautomation.com/u/Bruno_Burgin)\
**Post date:** [September 29, 2025, 4:55pm UTC](https://forum.inductiveautomation.com/t/data-request-for-csv-file/111067/1 "2025-09-29T16:55:42Z")

</div>

I have a request to export some historical data (21 tags) over a 2 month period in 1 hour increments. What’s the easiest way to export this data?

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [September 29, 2025, 5:05pm UTC](https://forum.inductiveautomation.com/t/data-request-for-csv-file/111067/2 "2025-09-29T17:05:11Z")

</div>

Make a script that uses [`system.tag.queryTagHistory`](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-tag/system-tag-queryTagHistory) to pull the data for all the tags that you need. Then, convert the returned dataset to a csv using [`system.dataset.exportCSV`](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-dataset/system-dataset-exportCSV).

For best results, create a [project library script](https://www.docs.inductiveautomation.com/docs/8.1/platform/scripting/scripting-in-ignition/project-library#add-a-script), and define the tags to read, as well as all the logic to fetch/convert and export in a function in this library, and call that function from whereever you need (like a button or gateway scheduled event) to export the data.

---

<div class="post-metadata">

**Author:** ![Bruno\_Burgin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bruno_burgin/32/80141_2.png) [@Bruno\_Burgin](https://forum.inductiveautomation.com/u/Bruno_Burgin)\
**Post date:** [September 29, 2025, 5:17pm UTC](https://forum.inductiveautomation.com/t/data-request-for-csv-file/111067/3 "2025-09-29T17:17:48Z")

</div>

Thank you for the help. Seems like a lot of work for a one-time export. Do you think it be easier on sql server?

---

<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:** [September 29, 2025, 5:18pm UTC](https://forum.inductiveautomation.com/t/data-request-for-csv-file/111067/4 "2025-09-29T17:18:28Z")

</div>

> [@Bruno\_Burgin](#):
>
> Do you think it be easier on sql server?

It will be much more difficult. The historian schema is not simple.

Consider dropping this Exchange project into your gateway:

> [@Tag Report Utility](https://forum.inductiveautomation.com/t/tag-report-utility/95299):
>
> New resource just uploaded to the Exchange (pending review). Also available here: [https://www.automation-pros.com/TagReportUtility/](https://www.automation-pros.com/TagReportUtility/) I intend to publish at this link as well as in the Exchange going forward. Announcements will be in this topic. (: Highlights: Provides a Perspective Popup View that provides a user interface to system.tag.query() that entirely replicates the functionality of the Designer's Tag Report Tool. Provides a Perspective Embedded View that provides Time Span selectio…

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [September 29, 2025, 5:53pm UTC](https://forum.inductiveautomation.com/t/data-request-for-csv-file/111067/5 "2025-09-29T17:53:21Z")

</div>

If you have designer access, this would be easy to do in the script console for a one time thing.

```python
tagList = [‘path/to/tag1’,‘path/to/tag2’,‘path/to/tag3’,‘path/to/tag4’]
sDate = system.date.getDate(2025,1,1)
eDate = system.date.getDate(2025,3,1)
retSize = system.date.hoursBetween(sDate,eDate)
dataSet = system.tag.queryTagHistory(paths=tagList, startDate=sDate, endDate=eDate, returnSize=retSize, returnFormat='Wide',includeBoundingValues=0,validateSCExec=0,timeout=60000)
	fileStartDate = system.date.format(system.date.parse(sDate, 'yyyy-MM-dd HH:mm'),'yyyyMMddHHmm')
	fileEndDate = system.date.format(system.date.parse(eDate, 'yyyy-MM-dd HH:mm'),'yyyyMMddHHmm')
	
	#Adjust file path if needed.
	newFilePath = 'C:\\TEMP\\_DataExport_' + fileStartDate + '-' + fileEndDate + '.csv'
	data = system.dataset.formatDates(endDS, 'yyyy/MM/dd HH:mm')
	csv = system.dataset.toCSV(dataset=data, showHeaders=True)
	system.file.writeFile(newFilePath, csv)

```

Adjust the variables above to match what you need of course, but this should get you started.

---

<div class="post-metadata">

**Author:** ![Bruno\_Burgin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bruno_burgin/32/80141_2.png) [@Bruno\_Burgin](https://forum.inductiveautomation.com/u/Bruno_Burgin)\
**Post date:** [October 20, 2025, 3:46pm UTC](https://forum.inductiveautomation.com/t/data-request-for-csv-file/111067/6 "2025-10-20T15:46:59Z")

</div>

![export](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/1/1114c7743fe14a52d7510eb0f22f8bc0e5188041.png)

Thanks for all the help, tweaked the code and ended up making our own reporting tool.
