Easy Chart - Save data for excel

I have historical data stored in no particular order with tag historian (default historical scan class with default settings, unlimited time between records). Now the customer is requesting all of last years historical data as an excel file with a fixed interval of one minute.

Obviously, my raw data isn’t in the required format so I’m attempting to export it via the easychart “save data for excel” function. It’s doing exactly what I’m looking for except I can’t seem to coerce it into minute intervals. Is this an option?

Any help much appreciated.

I don’t know if you can do it with the easy chart, but you could look into system.tag.queryTagHistory and system.dataset.exportExcel.

Specifically, look at the intervalMinutes argument for queryTagHistory.

1 Like

Personally for what your doing, if you want 1 minute intervals, I wouldn’t use the easy chart functions, I would create my own, you can use the easy chart to set a range, then give an export button with:

start = #set your start date
end = #set your end date
rs = system.date.minutesBetween(start,end)
tPaths = ['your tag path']

th = system.tag.queryTagHistory(paths=tPaths,startDate=start,endDate=end,returnSize=rs)

filePath = system.dataset.exportCSV("data.csv",1,th)

You still need to set your start and end date to use this, but you can link it to the start/end of your easy chart then put this in the action performed of a button.

1 Like

Thanks lads, that’s exactly what I’m looking for. I knew there had to be a better way.

Can you suggest the correct syntax to link the tPaths to the pen list of an Easy Chart? Ive got a dozen or so charts already setup and would like to use your solution for exporting better data, but cant seem to get the tags list working.

I can think of two quick examples if you replace:

tPaths = ['your tag path']


pensDS = event.source.parent.getComponent('Easy Chart').tagPens
pensDS = system.dataset.toPyDataSet(pensDS)
tPaths = []
for row in pensDS:


pensDS = event.source.parent.getComponent('Easy Chart').tagPens
tPaths = []
for x in range(pensDS.getRowCount()):

This is assuming you are using the tagPens for the easy chart. This is also assuming that your path to the easy chart is the same as what I showed.

Thanks for the speedy reply. We’ll give it a try.

No problem, you posted at the perfect time, I was checking the forum hoping the rain would slow down so I could walk to my car.

One other suggestion that is a little cleaner is:

pensDS = system.dataset.toPyDataSet(event.source.parent.getComponent('Easy Chart').tagPens)
tPaths = [row[1] for row in pensDS]
1 Like

I took your first suggestion and ran with it. I had originally tried the nested getComponent / toPyDataSet functions but couldnt quite get it. We’ve already got a chunk of the data exported and off to be polished so thanks again!