From: Oli Sanders Date: 2013-06-05T21:16:09+09:00 Subject: Re: Create a nested structure from a CSV Joel Pearson wrote in post #1111332: > Bah, my brain hurts too much to write a recursive hashifier at the > moment. > > Maybe this will help inspire you; I wrote something a while ago to do > this the other way around: Turning a nested Hash into a 2D Array > (although I still don't know how it works). ... thanks for the reply and the code. haven't been able to figure it out myself :) will keep trying. I'm thiking something like: def create_hierachy(csv_rows) csv_rows.each do |row| # New user hash user = {:user_name=>row['user_name'], :user_id=>row['user_id']} if row.is_supervisor=='t' # GET THE THE SUB-USERS users = csv_rows.collect{|r| r.supervisor_id==row.user_id}.compact user[:users] = create_hierarchy(users) end end end Just can't it it working :/ -- Posted via http://www.ruby-forum.com/.