system.tag.queryTagHistory Data Exporting Strangely

Hi All,

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

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

# 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 = (, "yyyy-MM-dd--HH-mm-ss"))
file_end_time_format = (, "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.


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.

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.

1 Like

Hi Irose,

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

Do you have any other ideas?