When I add a column to a dataset using the System.dataset.addColumn the values of the added column comes out with a lot of decimals even if I round them up before adding them to the python list.
This is the output excel, the last column is the one I added.
Any way to fix this?
dont use type float
double is not accepted int the function argument for some reason
seems like you should find the reason then xd
got some code i can look at?
XD
Here’s the code
dataset_query=system.dataset.toDataSet(sql_query)
paths_1=["[default]METEO/CARAVAGGIO/LivelloPioggia"]
col_caravaggio = []
date_from_mil=system.date.toMillis(date_from)
date_to_mil=system.date.toMillis(date_to)
time_frame=288 //1 day=12*24
time_frame_mil=time_frame*5*60*1000
for startDate_mil in range(date_from_mil,date_to_mil,time_frame_mil):
endDate_mil=startDate_mil+time_frame_mil-1000;
startDate=system.date.fromMillis(startDate_mil)
endDate=system.date.fromMillis(endDate_mil)
data_1 = system.tag.queryTagHistory(paths_1,startDate, endDate,1,"Average")
caravaggio = round(data_1.getValueAt(0,1),2)
col_caravaggio.append(caravaggio)
dataset_final=system.dataset.addColumn(dataset_query, col_caravaggio,"Caravaggio",float)
excel = system.dataset.toExcel(True, [dataset_final])
alright seems python doesnt have a double, but java has.
import java.lang.Double
and use it instead of float
dataset_final=system.dataset.addColumn(dataset_query, col_caravaggio,"Caravaggio",java.lang.Double)
1 Like
That's because jython's floats are double (always). The issue is that datasets are java, not jython, and need java column types.
1 Like