Sha256: 221598672df9c556fd9e94fd8c7a0eaacddc3079d7c3341dad54be1aebe477f4

Contents?: true

Size: 1.11 KB

Versions: 475

Compression:

Stored size: 1.11 KB

Contents

#!/usr/bin/env ruby

require 'rbbt-util'
require 'rbbt/util/simpleopt'

$0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands

options = SOPT.setup <<EOF
Transpose TSV

$ rbbt tsv transpose [options] file.tsv 

Display summary informations. Works with Tokyocabinet HDB and BDB as well.

-tch--tokyocabinet File is a TC HDB
-tcb--tokyocabinet_bd File is a TC BDB
-f--field* Field name for key
-hh--header_hash* Change the character used to mark the header line (defaults to #)
-h--help Help
EOF

SOPT.usage if options[:help]

file = ARGV.shift

file = case file
       when "-"
         STDIN
       when String
         Open.open(file)
       else
         raise ParameterException, "Please specify the tsv file as argument" if file.nil?
       end

field = options[:field]

options[:header_hash] = options["header_hash"]

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(file, options.merge(:type => :list))
end

puts tsv.transpose(field).to_s

Version data entries

475 entries across 475 versions & 1 rubygems

Version Path
rbbt-util-5.43.0 share/rbbt_commands/tsv/transpose
rbbt-util-5.42.0 share/rbbt_commands/tsv/transpose
rbbt-util-5.41.1 share/rbbt_commands/tsv/transpose
rbbt-util-5.41.0 share/rbbt_commands/tsv/transpose
rbbt-util-5.40.5 share/rbbt_commands/tsv/transpose
rbbt-util-5.40.4 share/rbbt_commands/tsv/transpose
rbbt-util-5.40.3 share/rbbt_commands/tsv/transpose
rbbt-util-5.40.0 share/rbbt_commands/tsv/transpose
rbbt-util-5.39.0 share/rbbt_commands/tsv/transpose
rbbt-util-5.38.1 share/rbbt_commands/tsv/transpose
rbbt-util-5.38.0 share/rbbt_commands/tsv/transpose
rbbt-util-5.37.16 share/rbbt_commands/tsv/transpose
rbbt-util-5.37.15 share/rbbt_commands/tsv/transpose
rbbt-util-5.37.14 share/rbbt_commands/tsv/transpose
rbbt-util-5.37.13 share/rbbt_commands/tsv/transpose
rbbt-util-5.37.12 share/rbbt_commands/tsv/transpose
rbbt-util-5.37.11 share/rbbt_commands/tsv/transpose
rbbt-util-5.37.10 share/rbbt_commands/tsv/transpose
rbbt-util-5.37.9 share/rbbt_commands/tsv/transpose
rbbt-util-5.37.8 share/rbbt_commands/tsv/transpose