Skip to content

Instantly share code, notes, and snippets.

@pragdave
Created October 15, 2010 19:50
Show Gist options
  • Save pragdave/628826 to your computer and use it in GitHub Desktop.
Save pragdave/628826 to your computer and use it in GitHub Desktop.
# Ask Nokogiri to find the row containing the header names
headers = table.search('thead > tr')
# Create a hash that maps the column name to the column index, so I can access subsequent
# rows' data by name
header_map = headers.search('th')
.map(&:text)
.each_with_index
.with_object({}) {|(name, index), hash| hash[name] = index}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment