Sha256: 86618b48a4fc9f6452724adfd8f61def9633740e920aaf535cfa8e64fa0b4014

Contents?: true

Size: 875 Bytes

Versions: 4

Compression:

Stored size: 875 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

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 = TSV.open(file)
end

tsv = tsv.slice(field) if field

tsv.each{|k,v| puts (Array === v ? v.flatten*"\t" : v.to_s ) }

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rbbt-util-5.7.0 share/rbbt_commands/tsv/values
rbbt-util-5.6.17 share/rbbt_commands/tsv/values
rbbt-util-5.6.16 share/rbbt_commands/tsv/values
rbbt-util-5.6.15 share/rbbt_commands/tsv/values