# Best way to remove a column from a json dataset

**URL:** <https://forum.inductiveautomation.com/t/best-way-to-remove-a-column-from-a-json-dataset/109046>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [July 29, 2025, 8:26am UTC](https://forum.inductiveautomation.com/t/best-way-to-remove-a-column-from-a-json-dataset/109046 "2025-07-29T08:26:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [July 29, 2025, 8:26am UTC](https://forum.inductiveautomation.com/t/best-way-to-remove-a-column-from-a-json-dataset/109046/1 "2025-07-29T08:26:44Z")

</div>

I have a dataset like this:

```python
[
{"VALUE1":"","VALUE2":""...},
{"VALUE1":"","VALUE2":""...},
{"VALUE1":"","VALUE2":""...},
]

```

What is the best way of removing a column?

`[i.pop("VALUE1") for i in dataset]`  
or

```python
#pseudo-code
dataset = system.dataset.toDataSet(headers, data)
dataset = system.dataset.filterColumns(!"VALUE2")
dataset = to.json.dataset(dataset)

```

_FYI: wanna delete that column only if is entirely empty (that's my current objective)._

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [July 29, 2025, 9:41am UTC](https://forum.inductiveautomation.com/t/best-way-to-remove-a-column-from-a-json-dataset/109046/2 "2025-07-29T09:41:46Z")

</div>

Ended up doing this:

```python
if not any([i.get("VALUE2") for i in value]):
	value = [i.pop("VALUE2") for i in value]

```

---

<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:** [July 29, 2025, 2:36pm UTC](https://forum.inductiveautomation.com/t/best-way-to-remove-a-column-from-a-json-dataset/109046/3 "2025-07-29T14:36:00Z")

</div>

Note that this is an inherently inefficient operation that's burning a lot of CPU to run through the list of rows ~twice. Depending on what else you need to do with this data, it might be worth reorganizing to have a single list-per-column in a dictionary per column name, and only 'translate' to this row-wise data structure at the end.

---

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [July 30, 2025, 7:24am UTC](https://forum.inductiveautomation.com/t/best-way-to-remove-a-column-from-a-json-dataset/109046/4 "2025-07-30T07:24:54Z")

</div>

I thought about that, but I ended doing something a bit different.

I used this:

> [@TIP - Converting a dataset column into a list](https://forum.inductiveautomation.com/t/tip-converting-a-dataset-column-into-a-list/38388/6):
>
> ds.getColumnAsList(ds.getColumnIndex("column"))

And did this:

```python
self.props.columns[6].visible = any(value.getColumnAsList(value.getColumnIndex("VALUE2")))

```

So only I show it if there is something to show. A bit different approach than what I first thought. Also this only gets executed at the start of the view. So even if it's a bit inefficient is only done 1 time.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [July 30, 2025, 7:44am UTC](https://forum.inductiveautomation.com/t/best-way-to-remove-a-column-from-a-json-dataset/109046/5 "2025-07-30T07:44:43Z")

</div>

This sound like an XY problem
