# CSV.Rows filter usage

**URL:** <https://discourse.julialang.org/t/csv-rows-filter-usage/72699>\
**Category:** New to Julia\
**Tags:** csv\
**Created:** [December 7, 2021, 8:04am UTC](https://discourse.julialang.org/t/csv-rows-filter-usage/72699 "2021-12-07T08:04:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vtomar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vtomar/32/18304_2.png) [@vtomar](https://discourse.julialang.org/u/vtomar)\
**Post date:** [December 7, 2021, 8:04am UTC](https://discourse.julialang.org/t/csv-rows-filter-usage/72699/1 "2021-12-07T08:04:53Z")

</div>

```julia
file = CSV.Rows(filename, header = 1; delim = ",", reusebuffer = true, 
            limit = 1000)

apply_filter(row) = !ismissing(row.Col1) && !ismissing(row.Col2)

output_string(row) = println("$(row.Col1) $(row.Col2)")

foreach(output_string, filter(apply_filter, file...))

```

can someone explain what is wrong with the code above? I was simply trying to get the row content in the csv file displayed in case the columns are not missing values.

---

<div class="post-metadata">

**Author:** ![lawless-m](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lawless-m/32/30869_2.png) [@lawless-m](https://discourse.julialang.org/u/lawless-m)\
**Post date:** [December 7, 2021, 8:43am UTC](https://discourse.julialang.org/t/csv-rows-filter-usage/72699/2 "2021-12-07T08:43:44Z")

</div>

Base.filter expects a collection, file is an Iterator

And no need for the splat …

this works

`foreach(output_string, Iterators.filter(apply_filter, file))`

Base.filter - [Collections and Data Structures · The Julia Language](https://docs.julialang.org/en/v1/base/collections/#Base.filter)

Iterators.filter - [Iteration utilities · The Julia Language](https://docs.julialang.org/en/v1/base/iterators/#Base.Iterators.filter)
