Auto pull historical data from the tag historian to ignition at certain times

Hello, I am wanting to pull all of the data for 3 tags from my tag historian to an excel sheet every sunday night. The data comes in at 5 minute increments. I know that I am missing something easy. I looked around and could find things that were close to what I was wanting but nothing was just right. If anyone could help that would be great!

There are a few ways to do this. One way would be to have an express tag like so

if(dateFormat(now(0), "E") = "Sun" && dateFormat(now(0), "HH:mm") = "22:30", 1, 0)

On the tag’s valueChange event put your code to run your logic

if currentValue.value == 1:
    script to run
1 Like

That works thank you! I think I figured out how to pull it to excel also.

I found this:

Create a variable that references our Power Table. You could modify this part
of the example to point to a different component in the window.

component = event.source.parent.getComponent(‘Table’)

Use system.dataset.toCSV to turn the dataset into a CSV string

csv = system.dataset.toCSV(

Write to local file system. Note the “r” character right before the directory path.
This denotes a raw string literal, meaning we ignore escape sequences (like the “/”)

system.file.writeFile(r"filepath/xxxx.csv", csv)