Skip to content

Instantly share code, notes, and snippets.

@maeharin
Created January 29, 2014 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maeharin/8680926 to your computer and use it in GitHub Desktop.
Save maeharin/8680926 to your computer and use it in GitHub Desktop.
lines = [
['user_code', 'sex', 'zangyo', 'q1', 'q2'],
['0001', '1', 'none', '1', '3'],
['0002', '1', 'none', '1', '3'],
['0003', '1', 'none', '1', '3'],
['0004', '1', 'none', '1', '3'],
['0005', '1', 'none', '1', '3']
]
heads = lines.shift.map(&:to_sym)
users = lines.map { |line| Hash[*heads.zip(line).flatten] }
p users
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment