lib/csv-hash.rb in csv-hash-0.1.1 vs lib/csv-hash.rb in csv-hash-0.1.2

- old
+ new

@@ -9,19 +9,19 @@ columns = [] FasterCSV.foreach(file) do |row| num += 1 if num == 1 - columns = row.collect {|c| c.strip} + columns = row.collect {|c| c.strip if c} next end hash = {} columns.each_with_index do |col, i| next unless col - col = col.strip - val = row[i].strip + col = col ? col.strip : nil + val = row[i] ? row[i].strip : nil setter = hash sp = col.split('__') sp.each_with_index do |key, j| if j == sp.size - 1 @@ -36,10 +36,10 @@ end data << hash end - return data, columns + return data, columns.compact end def to_string hashes, columns rows = hashes.collect do |hash| vals = columns.collect do |col| \ No newline at end of file