CSV.Rows filter usage

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.

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

Iterators.filter - Iteration utilities · The Julia Language

1 Like