Skip to content

Instantly share code, notes, and snippets.

@rdammkoehler
Created November 1, 2011 04:09
Show Gist options
  • Select an option

  • Save rdammkoehler/1329893 to your computer and use it in GitHub Desktop.

Select an option

Save rdammkoehler/1329893 to your computer and use it in GitHub Desktop.
readin' csv files
def read filename
@logger.info "reading #{filename}"
rows = CSV.read filename
@keys = rows.shift
@keys.collect! { |key| key.strip.intern }
rows.each { |row|
row_hash = {}
row.each_index { |index|
row_hash[@keys[index]] = row[index]
}
@rows << row_hash
}
@logger.debug "#{rows.length} rows read"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment