Sha256: 8dec710435a93c4699a7f516869dc94f72d44527e4db5ebec13ce647e538220d
Contents?: true
Size: 1.02 KB
Versions: 28
Compression:
Stored size: 1.02 KB
Contents
#!/usr/bin/env ruby require 'rbbt-util' require 'rbbt/util/simpleopt' options = SOPT.setup <<EOF Pulls the values from a tsv colum $ rbbt tsv values [options] <filename.tsv|-> Use - to read from STDIN -tch--tokyocabinet File is a tokyocabinet hash database -tcb--tokyocabinet_bd File is a tokyocabinet B database -f--field* Limit to a particular field -h--help Print this help -l--lines Separate in lines EOF rbbt_usage and exit 0 if options[:help] file = ARGV.shift file = STDIN if file == '-' case when options[:tokyocabinet] tsv = Persist.open_tokyocabinet(file, false) when options[:tokyocabinet_bd] tsv = Persist.open_tokyocabinet(file, false, nil, TokyoCabinet::BDB) else if String === file file = file.dup Path.setup(File.expand_path(file)) end tsv = file end field = options[:field] fields = field.nil? ? nil : [field] TSV.traverse(tsv, :fields => fields) do |k,v| if options[:lines] puts (Array === v ? v.flatten*"\n" : v.to_s ) else puts (Array === v ? v.flatten*"\t" : v.to_s ) end end
Version data entries
28 entries across 28 versions & 1 rubygems