From: Oli Sanders Date: 2013-06-04T23:11:14+09:00 Subject: Create a nested structure from a CSV Hello, I am parsing a CSV file which has rows like this: |user_name|user_id|supervisor_id|is_supervisor| | admin | 1 | 0 | t | | foo | 2 | 1 | t | | test | 3 | 2 | f | So from this I would like a hash that looks like: { :user_name=>'admin', :user_id=>1, :users=>[ {:user_name=>'foo', :user_id=>2, :users=>[ {:user_name=>'test',:user_id=>3} ] } ] } Basically, a user can have a supervisor, but each preceding supervisor can be supervised themselves. The problem is, there is an arbritary number of supervisors (user 'test' may supervise an additional user) so I think I need to solve this recursively. Can anyone help with the ruby-way to go about this? Thanks. -- Posted via http://www.ruby-forum.com/.