How to use CSV.filter to *filter out* rows from a CSV file #293
Replies: 1 comment
-
We can't remove any rows by |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Sorry if this is a silly question but I haven't been able to find an answer yet.
It seems all the examples I've encountered for CSV.filter are actually doing transformations on the rows but none are filtering out any rows.
I see examples like this:
CSV.filter(in_io, out_string) do |row| row[0] = row[0].upcase row[1] *= 4 end
but not like this:
CSV.filter(in_io, out_string) do |row| // logic to determine if row should be included or excluded // return row if should be included, return nil if should be excluded? end
My attempts to getting something like that to work have not worked so far.
Did I misinterpret what CSV.filter is supposed to do, or am I missing something?
Beta Was this translation helpful? Give feedback.
All reactions