Sha256: 32744f46abcbf73166e8312e1359ed2d1f0a3c4604fb2118117ce8bd16fc25d9
Contents?: true
Size: 478 Bytes
Versions: 4
Compression:
Stored size: 478 Bytes
Contents
#!/usr/bin/env ruby require "faster_csv" class CSVConduit def self.pack(data) headers = data[0].attribute_names headers.to_csv + data.map{ |rec| headers.map{ |header| rec.send(header) }.to_csv(:force_quotes => true) }.join end def self.unpack(data) rows = FasterCSV.parse(data) attribs = rows.delete_at(0) attribs = attribs.map{|atr| atr.to_sym} records = rows.map{|row| Hash[*attribs.zip(row).flatten]} end end
Version data entries
4 entries across 4 versions & 1 rubygems