Sha256: c56af85dab1fa98a2821a73e8fbf44b0ce7946acedf05b3667764bbc28de0d71

Contents?: true

Size: 1.04 KB

Versions: 67

Compression:

Stored size: 1.04 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
Zip fields in a TSV file 

$ rbbt tsv info [options] file.tsv

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

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

SOPT.usage if options[:help]

file = ARGV.shift

file = STDIN if file == '-'

field = options[:field] || 0
merge = options[:merge] || false

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, {:type => :double}.merge(options))
end

puts tsv.unzip(field, merge).to_s

Version data entries

67 entries across 67 versions & 1 rubygems

Version Path
rbbt-util-5.15.1 share/rbbt_commands/tsv/unzip
rbbt-util-5.14.39 share/rbbt_commands/tsv/unzip
rbbt-util-5.14.38 share/rbbt_commands/tsv/unzip
rbbt-util-5.14.37 share/rbbt_commands/tsv/unzip
rbbt-util-5.14.36 share/rbbt_commands/tsv/unzip
rbbt-util-5.14.35 share/rbbt_commands/tsv/unzip
rbbt-util-5.14.34 share/rbbt_commands/tsv/unzip
rbbt-util-5.14.33 share/rbbt_commands/tsv/unzip
rbbt-util-5.14.32 share/rbbt_commands/tsv/unzip
rbbt-util-5.14.31 share/rbbt_commands/tsv/unzip
rbbt-util-5.14.30 share/rbbt_commands/tsv/unzip
rbbt-util-5.14.29 share/rbbt_commands/tsv/unzip
rbbt-util-5.14.28 share/rbbt_commands/tsv/unzip
rbbt-util-5.14.26 share/rbbt_commands/tsv/unzip
rbbt-util-5.14.25 share/rbbt_commands/tsv/unzip
rbbt-util-5.14.24 share/rbbt_commands/tsv/unzip
rbbt-util-5.14.23 share/rbbt_commands/tsv/unzip
rbbt-util-5.14.22 share/rbbt_commands/tsv/unzip
rbbt-util-5.14.21 share/rbbt_commands/tsv/unzip
rbbt-util-5.14.20 share/rbbt_commands/tsv/unzip