Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSV::Row does not have .to_h #2315

Closed
mjc opened this issue Dec 12, 2014 · 2 comments
Closed

CSV::Row does not have .to_h #2315

mjc opened this issue Dec 12, 2014 · 2 comments

Comments

@mjc
Copy link
Contributor

@mjc mjc commented Dec 12, 2014

jruby 1.7.17

CSV.read(file_name,headers: true).first.to_h
NoMethodError: undefined method `to_h' for #<CSV::Row:0x68ab0936>

jruby 9k (7a66d8b)

CSV.read(file_name,headers: true).first.to_h
NoMethodError: undefined method `to_h' for #<CSV::Row:0xb4a2758>

This works on MRI 2.1.0 and possibly older versions as well - it creates a hash with the headers of the CSV as the keys.

@headius
Copy link
Member

@headius headius commented Dec 15, 2014

This does not work in MRI 1.9 or 2.0 either, so it appears to be a change in 2.1. It won't be fixed in JRuby 1.7.x, but we will fix it in 9k (which will be 2.2 compatible).

We run a direct copy of csv.rb from MRI, so there's something else at play here.

@headius
Copy link
Member

@headius headius commented Dec 15, 2014

Enumerable gained to_h in 2.1. Fixing.

@headius headius added this to the JRuby 9.0.0.0 milestone Dec 15, 2014
@headius headius self-assigned this Dec 15, 2014
@headius headius removed this from the JRuby 9.0.0.0 milestone Jan 16, 2015
@headius headius added this to the JRuby 9.0.0.0-pre1 milestone Jan 16, 2015
@headius headius added this to the JRuby 9.0.0.0-pre1 milestone Jan 16, 2015
@headius headius removed this from the JRuby 9.0.0.0 milestone Jan 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants