PyTypes and system.dataset.addColumn()

Hi,

I’m trying to use system.dataset.addColumn().

The last argument is giving me trouble. The user manual says [quote] PyType colType - The type of the of the column. The type can be the Python equivalent of String, Long, Double, Short, Integer, Float, Boolean, null, or java.util.Date if they exist. [/quote]

I’m pretty sure I can figure out the PyTypes that relate to most of the native Python types: str, long, double, short, int, float, bool. … but I can’t figure out the date one.

Anyone know?

You could use the [color=#FF00FF]type[/color] python function to get the date type when adding a column:

tbl = event.source.parent.getComponent("Table")

now = system.tag.read("[System]Client/System/CurrentDateTime").value
col = []
for i in range(tbl.data.getRowCount()):
[ul]col.append(now)[/ul]
tbl.data = system.dataset.addColumn(tbl.data,col,“DateTime”,[b][color=#FF00FF]type[/color]/b)

Is it possible to append a date or dateTime type column with system.dataset.addColumn()?

Yes. Use java.util.Date for the type.

So simple…forgot to import the library. Thank you Jordan!

1 Like

Another column add question - is it possible to add a Color type column to a dataset?
I have attempted to use something like below, but have not been successful.

newData = system.dataset.addColumn(data,colorData,'colorCode',java.awt.Color)

Per the documentation

If I try this I get an error saying that java.awt.color can not be coerced into a PyType.

You can use the DatasetBuilder utility class.