Hey everyone,
I am using:
system.tag.queryTagHistory(paths=tagPaths, startDate=previousRunStartTime, endDate=RunEndTime, returnSize=3600, aggregationMode="LastValue")
to pull data for CSV
It works great but I when it sends to the csv all values that are floats have 7+ decimal points I would like to narrow it down to just 2 or 3. Is there a simple way of doing that within Ignition or is my only option to script it?
Tip: the first two or three lines of your block of code aren't formatted properly and so have lost their indentation. Please see Wiki - how to post code on this forum.
An easy way would be to use a function kinda like this one:
def round_2(v):
try:
return round(v, 2)
except:
return v
and pass the value to this function:
values = [round_2(history.getValueAt(row, col)) for col in range(1, history.getColumnCount())]
edit:
I'm using try
here instead of something like if isinstance(v, float)
just in case the values are not actually float
but some other type/wrapper. If you can confirm the type, it's maybe better to just check it.
yes thank you I did something similar to this