Class: EMaily::CSV
- Inherits:
-
Object
- Object
- EMaily::CSV
- Defined in:
- lib/emaily/csv.rb
Class Method Summary collapse
Class Method Details
.parse(file) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/emaily/csv.rb', line 3 def self.parse(file) list = [] f = File.open(file, "r") lines = f.readlines fields = lines[0].downcase.strip.split(",") lines.delete(lines[0]) lines.each_with_index do |line, i| list[i] = {} line.chop.split(",").each_with_index do |val, idx| list[i][fields[idx].strip.to_sym] = val.strip end end list end |