System.tag.queryTagHistory Return format

Hi, I'm using the WebDev module to return information for some tags, all good but the client want just headers and data and not the others parts like names or number of rows. There is a way to just send data and header and not the other data.

data= system.tag.queryTagHistory(
		paths=tags, startDate= startTime, endDate= endTime, returnSize= rtnSize, aggregationMode=aggMode, intervalMinutes=5, returnFormat="Wide")

"#NAMES"
"timestamp","xxx/Device/PowerMeter/MTR/q3_kvar","xxx/Device/PowerMeter/MTR/v3_kV"
"#TYPES"
"str","D","D"
"#ROWS","12"
"2024-07-12 17:00:00-0500","-15.549358989101018","142.35860947782382"
"2024-07-12 17:05:00-0500","-15.51349731553694","142.3569471673588"
"2024-07-12 17:10:00-0500","-15.570315025464","142.35528485689383"
"2024-07-12 17:15:00-0500","-15.649438029540292","142.3536225464288"
"2024-07-12 17:20:00-0500","-16.2490010706542","142.35196023596376"

Post your whole script, but it looks like you're using the system.dataset.toCsv function and just need to force the parameter that allows you to import a CSV dataset back into Ignition to false.

1 Like
def getHistoricalData(tags, startTime, endTime, rtnSize, aggMode):
	'''
	Query tag history on the list of tags - returns datset
	'''
	data= system.tag.queryTagHistory(
		paths=tags, startDate= startTime, endDate= endTime,
#		returnSize= rtnSize, aggregationMode=aggMode, intervalMinutes=1, returnFormat="Wide")
		returnSize= rtnSize, aggregationMode=aggMode, intervalMinutes=5, returnFormat="Wide")
	return data

results = API.getHistoricalData(tags, startTime, endTime, returnSize, aggMode)
csvFile = system.dataset.toCSV(results, forExport=1)

this is the solution, thanks
csvFile = system.dataset.toCSV(ds_utc, forExport=0)

1 Like