Sha256: 0a006158689728e224ccd0b6d2dfc1fa0e972140bceaf19f4ec1674d7c4fcd27
Contents?: true
Size: 750 Bytes
Versions: 833
Compression:
Stored size: 750 Bytes
Contents
#!/usr/bin/env ruby require 'rbbt-util' require 'rbbt/util/simpleopt' options = SOPT.get("-tch--tokyocabinet:-tcb--tokyocabinet_bd:-m--melt:-s--snake_case") file = ARGV.shift case when options[:tokyocabinet] tsv = Persist.open_tokyocabinet(file, false) when options[:tokyocabinet_bd] tsv = Persist.open_tokyocabinet(file, false, nil, TokyoCabinet::BDB) else tsv = TSV.open(Open.open(file)) end fields = tsv.fields if options[:snake_case] tsv.fields = fields = fields.collect{|f| Misc.snake_case f} end raise "No fields specified" if fields.nil? if options[:melt] puts tsv.to_hash.collect{|key, values| h = {:key => key} fields.zip(values).each do |field, v| h[field] = v end h }.to_json else puts tsv.to_hash.to_json end
Version data entries
833 entries across 833 versions & 1 rubygems