lib/csv-hash.rb in csv-hash-0.1.0 vs lib/csv-hash.rb in csv-hash-0.1.1
- old
+ new
@@ -42,11 +42,11 @@
end
def to_string hashes, columns
rows = hashes.collect do |hash|
vals = columns.collect do |col|
- sp = col.split('__')
+ sp = col.to_s.split('__')
ret = hash
sp.each do |key|
puts key unless ret
ret = ret[key]
end
@@ -64,9 +64,10 @@
end
end
end
end
+# Pass either a path to a csv file to parse which will return an array of hashes (stringified keys) or pass an array of hashes and an array of column names
def CSVHash arg, columns=nil
if arg.is_a?(File)
CSVHash.from_file(arg.path)
elsif arg.is_a?(String)
CSVHash.from_file(arg)
\ No newline at end of file