[ruby-core:85818] [Ruby trunk Feature#13706][Closed] Allow CSV#delete to delete multiple columns or add #delete_columns method

From: hsbt@...
Date: 2018-02-26 11:17:49 UTC
List: ruby-core #85818
Issue #13706 has been updated by hsbt (Hiroshi SHIBATA).

Status changed from Open to Closed
Assignee set to kou (Kouhei Sutou)

https://github.com/ruby/csv/pull/4 was already merged.

----------------------------------------
Feature #13706: Allow CSV#delete to delete multiple columns or add #delete_columns method
https://bugs.ruby-lang.org/issues/13706#change-70675

* Author: wowinter13 (Vladislav Dyachenko)
* Status: Closed
* Priority: Normal
* Assignee: kou (Kouhei Sutou)
* Target version: 
----------------------------------------
I duplicated the main report message from this PR: https://github.com/ruby/csv/pull/4
The basic idea is that now we can delete only one column using #delete

`csv_table.delete("PassengerId")
csv_table.delete("Survived")
csv_table.delete("Name")
csv_table.to_csv`

The best working way for me to do it with multiple columns:
`
to_del = ["Name", "Ticket"]
csv_table = datus.by_col!.delete_if { |name, values| !to_del.include? name}`

But maybe it should work like this?
`
to_del = ["Name", "Ticket"]
data.delete(to_del)`




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next