Sha256: 753ee71f0626a159ecbae4ba0c2956399381526bbd518d8403476a700ea97991
Contents?: true
Size: 1009 Bytes
Versions: 317
Compression:
Stored size: 1009 Bytes
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] TSV.traverse(tsv, :fields => [field]) 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
317 entries across 317 versions & 1 rubygems