# system.dataset.filterColumns using CSV

**URL:** <https://forum.inductiveautomation.com/t/system-dataset-filtercolumns-using-csv/21385>\
**Category:** Ignition\
**Created:** [December 12, 2018, 7:54pm UTC](https://forum.inductiveautomation.com/t/system-dataset-filtercolumns-using-csv/21385 "2018-12-12T19:54:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [December 12, 2018, 7:54pm UTC](https://forum.inductiveautomation.com/t/system-dataset-filtercolumns-using-csv/21385/1 "2018-12-12T19:54:55Z")

</div>

I’m trying to filter multiple columns of a dataset using another dataset. I’m currently attempting to use the dataset to filter with by converting it to a CSV using `system.dataset.toCSV`, then using that as the list of column names to filter by in the `filterColumn` function. It doesn’t seem to work though. Anyone got any ideas on how to do this?

```auto
dataIn = event.source.data
ds = system.tag.read("datasetTag").value
list = system.dataset.toCSV(ds,0)

filter = system.dataset.filterColumns(dataIn, list)

```

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [December 12, 2018, 8:04pm UTC](https://forum.inductiveautomation.com/t/system-dataset-filtercolumns-using-csv/21385/2 "2018-12-12T20:04:10Z")

</div>

This should work.

```auto
dataIn = event.source.data
ds = system.tag.read("datasetTag").value
list = system.dataset.getColumnHeaders(ds)

filter = system.dataset.filterColumns(dataIn, list)

```

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [December 12, 2018, 8:19pm UTC](https://forum.inductiveautomation.com/t/system-dataset-filtercolumns-using-csv/21385/3 "2018-12-12T20:19:11Z")

</div>

Hmm. this might work if I change how the dataset tag is setup. Currently, the dataset tag has one, arbitrary header and the columns to filter by are rows. I can probably change it to a dataset tag with all column headers and no rows, then I can utilize the `getColumnHeaders`

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [December 12, 2018, 8:37pm UTC](https://forum.inductiveautomation.com/t/system-dataset-filtercolumns-using-csv/21385/4 "2018-12-12T20:37:34Z")

</div>

Oh, I see. You could do it without changing the dataset fairly easily as well.

```auto
list = [ds.getValueAt(row, 0) for row in range(ds.rowCount)]

```

Of course if the item you want to filter on isn’t in column 0 you will need to change the script accordingly.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [December 12, 2018, 8:54pm UTC](https://forum.inductiveautomation.com/t/system-dataset-filtercolumns-using-csv/21385/5 "2018-12-12T20:54:57Z")

</div>

When I do this, it works but the values i’m getting are like `u'Inspect'` instead of `Inspect` so the `filterColumns` isn’t working

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [December 12, 2018, 9:18pm UTC](https://forum.inductiveautomation.com/t/system-dataset-filtercolumns-using-csv/21385/6 "2018-12-12T21:18:49Z")

</div>

> [@dkhayes117](#):
>
> u'Inspect'

That is how items in the list print to console. It is indicating that the value in the list is a unicode string with the value of Inspect.

A list of unicode strings should work just fine for system.dataset.FilterColumns().

Have you verified that all of the values in the list are valid column names in your dataIn dataset? They will have to match exactly including case.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [December 12, 2018, 9:24pm UTC](https://forum.inductiveautomation.com/t/system-dataset-filtercolumns-using-csv/21385/7 "2018-12-12T21:24:35Z")

</div>

Gotcha, I’m not sure what happened, but it is working now. It must have been a typo in the code by me. It is working, thank you!
