# system.tag.queryTagHistory Data Exporting Strangely

**URL:** <https://forum.inductiveautomation.com/t/system-tag-querytaghistory-data-exporting-strangely/59605>\
**Category:** Ignition\
**Tags:** python, ignition81, scripting, vision, database\
**Created:** [May 16, 2022, 10:42am UTC](https://forum.inductiveautomation.com/t/system-tag-querytaghistory-data-exporting-strangely/59605 "2022-05-16T10:42:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Reilly](https://avatars.discourse-cdn.com/v4/letter/j/85e7bf/32.png) [@John\_Reilly](https://forum.inductiveautomation.com/u/John_Reilly)\
**Post date:** [May 16, 2022, 10:42am UTC](https://forum.inductiveautomation.com/t/system-tag-querytaghistory-data-exporting-strangely/59605/1 "2022-05-16T10:42:15Z")

</div>

Hi All,

I am collecting data of lots of tags and am able to display the results as shown below in the Vision client.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/e/ce18fb70e230ae7987539260b58a465adaf3f1d9.png)

I need to extract the true values of this graph but when I press the save button on the graph I get an interpolation of the data (sample rate of the graph) but I need every value of that tag which makes that graph.

I came across the system.tag.queryTagHistory example on the ignition documentation [Export Tag Historian to CSV](https://docs.inductiveautomation.com/display/DOC79/Export+Tag+Historian+to+CSV)

```auto
# First we start by creating a start and end time that we will be query history for.
endTime = event.source.parent.getComponent('Date Range').endDate
startTime = event.source.parent.getComponent('Date Range').startDate

 
# Next we call our queryTagHistory function, using the start and end dates as well as a Tag path.
# The other parameters listed for this function can be altered to fit your need.
data = system.tag.queryTagHistory(paths=["[default]Hot_Workshop/CMI_Furnace/ROOF_0104_300_03_TC"],
startDate=startTime, endDate=endTime, returnSize=0)
 
# Turn that history data into a CSV.
csv = system.dataset.toCSV(data)
 
# Making File export name related to date range
file_start_time_format = (system.date.format(startTime, "yyyy-MM-dd--HH-mm-ss"))
file_end_time_format = (system.date.format(endTime, "yyyy-MM-dd--HH-mm-ss"))
file_name = (r"C:\myExports\CMI-%s-%s.csv")
file_name = file_name % (file_start_time_format,file_end_time_format)
# Export that CSV to a specific file path. The r forces it to use the raw path and not require double backslashes.
system.file.writeFile(file_name, csv)

```

Above is the exact verion of thecode being used. Not really different to the example in the link.

However when I use this export I get a graph that looks like this which is missing a lot of the data points to make the graph identical to Vision client.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/2/d234a4d7339d14c592db79f7c59b758b0e0ac6d3.png)

**Have I misunderstood something about system.tag.queryTagHistory or the Iginition Platform?**

For the graph to be generated in Ignition there must be additional data points, **any help is greatly apprecaited.**

Thank you very much in advanced.  
John

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [May 16, 2022, 11:47am UTC](https://forum.inductiveautomation.com/t/system-tag-querytaghistory-data-exporting-strangely/59605/2 "2022-05-16T11:47:26Z")

</div>

Try using -1 as the return size.

0 will tell the function to return the “natural” number of values based on the logging rates of the scan classes.

-1 will tell the function to return the values as they changed.

You may also want to set `noInterpolation = True` to insure that no interpolated values are returned.

---

<div class="post-metadata">

**Author:** ![John\_Reilly](https://avatars.discourse-cdn.com/v4/letter/j/85e7bf/32.png) [@John\_Reilly](https://forum.inductiveautomation.com/u/John_Reilly)\
**Post date:** [May 16, 2022, 2:47pm UTC](https://forum.inductiveautomation.com/t/system-tag-querytaghistory-data-exporting-strangely/59605/3 "2022-05-16T14:47:00Z")

</div>

Hi Irose,

I’ve tried those parameters and still get the exact same dataset.

Do you have any other ideas?

Thanks,  
John
