I wanted to Call System.dataset.addRow() like ignition method from java

I found one class DatasetUtilities, In which I found the addRow method, but this method required PySequence row, but I don’t know how to create a PySequence row in java.

Use a com.inductiveautomation.ignition.common.util.DatasetBuilder instead.
The code in DatasetUtilities is basically equivalent to this:

    public static Dataset addRow(Dataset ds, Object[] newRow) {
        var builder = DatasetBuilder.newBuilder().colNames(ds.getColumnNames()).colTypes(ds.getColumnTypes());
        for (int i = 0; i < ds.getRowCount(); i++) {
            var row = new Object[ds.getColumnCount()];
            for (int j = 0; j < ds.getColumnCount(); j++) {
                row[j] = ds.getValueAt(i, j);
            }
            builder.addRow(row);
        }
        builder.addRow(newRow);
        
        return builder.build();
    }

Thankyou for replying,
But, for my module building I need all the system.datatset. methods.
for exmaple system.dataset.todataset(), system.dataset.deleteRow(). for that I need PySequence row, PySequence headers etc.
I need help regarding PySequence

You really don’t. Work with datasets directly.

If you, for whatever reason, particularly want a PySequence, then you can make a PyList from a Java list; just call the constructor.

1 Like