Sha256: 8d6b5f4eb02f6ba09936a3a5ddf1b79b4d95e6fdff0aa83e405a32cf81d79ca9
Contents?: true
Size: 1.13 KB
Versions: 464
Compression:
Stored size: 1.13 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 -k--keys Print also keys -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 ) elsif options[:keys] puts(k << "\t" << (Array === v ? v.flatten*"\t" : v.to_s )) else puts (Array === v ? v.flatten*"\t" : v.to_s ) end end
Version data entries
464 entries across 464 versions & 1 rubygems