# Filtering dataset using .remove() on column names list

**URL:** <https://forum.inductiveautomation.com/t/filtering-dataset-using-remove-on-column-names-list/107486>\
**Category:** Ignition\
**Tags:** scripting, perspective\
**Created:** [June 17, 2025, 4:30pm UTC](https://forum.inductiveautomation.com/t/filtering-dataset-using-remove-on-column-names-list/107486 "2025-06-17T16:30:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roman\_Rozenshteyn](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@Roman\_Rozenshteyn](https://forum.inductiveautomation.com/u/Roman_Rozenshteyn)\
**Post date:** [June 17, 2025, 4:30pm UTC](https://forum.inductiveautomation.com/t/filtering-dataset-using-remove-on-column-names-list/107486/1 "2025-06-17T16:30:44Z")

</div>

I'm having issues with what seems to be a straightforward task. Here's what I need:

System is setup with a pre-populated dataset tag

1. User selects a column name from a dropdown (which is assembled based on the column names of the dataset tag)
2. My script takes the selection and tries to remove it from the list of dataset column names
3. Then the scrip applies the modified list of column names to the `system.dataset.filterColumns(dataset, columns)` function
4. Finally the new dataset is written back to the tag

Here's where my issues starts. It appears that the column name list has some additional formatting ([`u'Item 1'...u'Item N'`]) characters and the .remove() method does not work.

This is the piece of the code that's giving me trouble:

```python
item_to_remove = 'Bob'
existing_dataset = system.tag.readBlocking([dataset_tag])[0].value
name_list = existing_dataset.getColumnNames()

name_list.remove(item_to_remove)

```

And this is the error message:  
`Error running action 'component.onActionPerformed' on Docks/_Common/Recipe Delete@D/root/rflexButtons/btnOk: Traceback (most recent call last): File "<function:runAction>", line 15, in runAction File "<function:runAction>", line 15, in runAction at java.base/java.util.Collections$UnmodifiableCollection.remove(Unknown Source) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.lang.UnsupportedOperationException: java.lang.UnsupportedOperationException`

Any throughs and/or workaround suggestions?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [June 17, 2025, 4:44pm UTC](https://forum.inductiveautomation.com/t/filtering-dataset-using-remove-on-column-names-list/107486/2 "2025-06-17T16:44:31Z")

</div>

> [@Roman\_Rozenshteyn](#):
>
> ```python
> item_to_remove = 'Bob'
> existing_dataset = system.tag.readBlocking([dataset_tag])[0].value
> name_list = existing_dataset.getColumnNames()
> 
> name_list.remove(item_to_remove)
> 
> ```

~~Should that be,~~

```python
item_to_remove = 'Bob'
existing_dataset = system.tag.readBlocking([dataset_tag])[0].value
name_list = system.dataset.getColumnHeaders(existing_dataset)

name_list = [item for item in name_list if item not in [item_to_remove]]

```

I'm not a Python expert, ~~but the remove() function expects an index so to use that you would need to know what position 'Bob' was in first. It will also, as far as I know, error if 'Bob' doesn't show up.~~

I am incorrect. See [Python List remove() Method](https://www.w3schools.com/python/ref_list_remove.asp).

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 17, 2025, 4:48pm UTC](https://forum.inductiveautomation.com/t/filtering-dataset-using-remove-on-column-names-list/107486/3 "2025-06-17T16:48:51Z")

</div>

> [@Roman\_Rozenshteyn](#):
>
> It appears that the column name list has some additional formatting ([`u'Item 1'...u'Item N'`]) characters and the .remove() method does not work.

That's not your problem.

Tangent, explaining what's going on:  
The `u` artifacts you see when you print out a list's contents are a formatting artifact _of the list itself_ - by default, Python prints the items inside the list using their ` __repr__ ` implementation. In Python **2** , there are two fundamental types of strings - unicode and ASCII, and the `u` prefix distinguishes them. It's indicating that to create an equivalent literal in your own code, you would have to prefix the string, just as it shows up in the debug output - but as long as the characters are the same, you can search for an ASCII string literal inside a unicode string just fine.

Your actual problem is this:

```python
java.util.Collections$UnmodifiableCollection.remove(Unknown Source) 
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
java.lang.UnsupportedOperationException: java.lang.UnsupportedOperationException

```

Jython wraps all Java list types in a list-like type, so you _have_ the `remove` function. But the list **instance** you are getting is an `UnmodifiableCollection`, which does not allow you to remove elements - it's unmodifiable. Because you're dealing with a list of strings, you can get away with a "shallow copy" to a standard Python/Jython list:

```python
item_to_remove = 'Bob'
existing_dataset = system.tag.readBlocking([dataset_tag])[0].value
name_list = list(existing_dataset.getColumnNames())

name_list.remove(item_to_remove)

```

And the rest of your code should work.
