system.dataset.addColumn bug?

Hello

I am running Ignition 7.9.6 and trying to add a column to a dataset with some None values, with unexpected results. See the code snippet below.

ds = system.dataset.toDataSet(['Id', 'Name'], 
	[[1, 'Nick'], [2, 'Joe'], [3, 'Larry']])
newColumn = [None, 'Shmoe', None]
ds = system.dataset.addColumn(ds, 
	newColumn,
	'LastName',
	str
	)

for r in range(ds.rowCount):
	print '\t'.join(str(ds.getValueAt(r, c))\
		for c in range(ds.columnCount))

# Expected result
#1	Nick	None
#2	Joe	Shmoe
#3	Larry	None

# Output
#1	Nick	None
#2	Joe	Shmoe
#3	Larry	Shmoe

Am I doing something wrong or is this a bug?

Known bug. See this thread.

Alright thanks. If anyone else runs into this, you can workaround it by creating a new column with only None, then iterating through it and setting values.

# ds is a dataset from somewhere
colIndex = ds.columnCount
ds = system.dataset.addColumn(ds, 
		[None]*ds.rowCount,
		'Col Name',
		str
		)
indexes = [2, 3]
values = ['x', 'y']
for rowIndex, value in zip(indexes, values):
	ds = system.dataset.setValue(ds, rowIndex, colIndex, value )

It’s been fixed in 7.9.8. :grinning:

1 Like