Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cvs2json cannot load such file -- orderedhash

Tags:

ruby

gem

I'm trying to use this gem: csv2json (0.3.0) and I'm getting an error.

On my file essaie.rb:

require 'csv2json'

File.open('essaie.csv', 'r') do |input|
    File.open('output.json', 'w') do |output|
        CSV2JSON.parse(input, output)
    end
end


user@user-ThinkPad-L430:~/development/public/opendata/other$ ruby essaie.rb 
/home/user/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- orderedhash (LoadError)
    from /home/user/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /home/user/.rvm/gems/ruby-2.1.0/gems/csv2json-0.3.0/lib/csv2json.rb:4:in `<top (required)>'
    from /home/user/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `require'
    from /home/user/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
    from /home/user/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
    from essaie.rb:1:in `<main>'

When I remove the version 0.3.0(csv2json) and I installed the previous version I'm getting this error:

user@user-ThinkPad-L430:~/development/public/opendata/other$ ruby essaie.rb 
/home/user/.rvm/gems/ruby-2.1.0/gems/csv2json-0.2.0/lib/csv2json.rb:17:in `initialize': wrong number of arguments (2 for 0) (ArgumentError)
    from /home/user/.rvm/gems/ruby-2.1.0/gems/csv2json-0.2.0/lib/csv2json.rb:17:in `new'
    from /home/user/.rvm/gems/ruby-2.1.0/gems/csv2json-0.2.0/lib/csv2json.rb:17:in `parse'
    from essaie.rb:5:in `block (2 levels) in <main>'
    from essaie.rb:4:in `open'
    from essaie.rb:4:in `block in <main>'
    from essaie.rb:3:in `open'
    from essaie.rb:3:in `<main>'

any help?

notes : file name essaie.csv contains the same data as input.csv (from the example of the documentation)

like image 998
Papouche Guinslyzinho Avatar asked Jun 08 '14 04:06

Papouche Guinslyzinho


1 Answers

Just ran into this myself. Looks like they just forgot a dependency. Gems come with a list of other gems they require, but this developer probably had the orderedhash gem installed already and didn't pay attention to the need for it to be part of the dependency list for csv2json.

I typed:

gem install orderedhash

And then csv2json worked just fine for me.

See also a github issue recently opened about this:

https://github.com/darwin/csv2json/issues/12

like image 197
Tom Boutell Avatar answered Oct 24 '22 03:10

Tom Boutell