if I want to remove the number 20 for example in the dataset of type 4x1
NameColumn
30
20
12
10
I use this line of code: dsDevice = self.view.params.listZoneDesservies # dataset dsDevice = system.dataset.deleteRow(dsDevice,self.view.params.idZone)
The problem is that I know the value I want to delete but not its index.
In the dataset, each value will be unique. so if I can delete a value without knowing its index, that would be good
What function should I use to remove the value without knowing its index in the dataset?
here is the script i made to delete one value, it works.
first I check if the value I want to delete exists in the dataset
dsZone = self.view.params.DeviceZone #dataset
if self.view.params.idDevice in dsZone.getColumnAsList(0):
for i in range(dsZone.getRowCount()):
if dsZone.getValueAt(i, 'listDevice') == self.view.params.idDevice:
dsZone = system.dataset.deleteRow(dsZone,i)
system.tag.writeBlocking([zonePath],[dsZone])
break
Why ? You're already doing that with the inner if.
And if you're converting the column to a list, might as well use that to find the index instead of going through your dataset in a loop...
Use one of the scripts above. They have the added advantage of being reusable.
But again, do you NEED a dataset tag for just one column ? It's been several threads were you're doing list operation on that same one column dataset, and it seems to me you could make your life simpler by using an array instead...
Yes I'am doing operation on that same one column dataset because the person who created the dataset type tag did not use the array. This is the reason why I'am using same type of data.
it's true that it would be easier to use array.
And I nedd delete one row not a list of value from dataset reason why I'am using deleteRow and not deleteRows
You keep harping on using an array instead of a dataset. Unless you are using Perspective, and this topic is agnostic on that point (because the algorithms apply anywhere), datasets are much more platform-friendly. In particular, Vision doesn't have a client-side custom property type for arrays.
Please confine your array advice to situations where it is known that the data is only going to be used in Perspective.