Created
November 1, 2011 04:09
-
-
Save rdammkoehler/1329893 to your computer and use it in GitHub Desktop.
readin' csv files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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