Sha256: ace7dbf33cd0220e05058f4545d2642f8b7ae1fcc4573239cece46344b9c066f

Contents?: true

Size: 1.04 KB

Versions: 174

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 unzip [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

174 entries across 174 versions & 1 rubygems

Version Path
rbbt-util-5.18.1 share/rbbt_commands/tsv/unzip
rbbt-util-5.18.0 share/rbbt_commands/tsv/unzip
rbbt-util-5.17.89 share/rbbt_commands/tsv/unzip
rbbt-util-5.17.88 share/rbbt_commands/tsv/unzip
rbbt-util-5.17.87 share/rbbt_commands/tsv/unzip
rbbt-util-5.17.86 share/rbbt_commands/tsv/unzip
rbbt-util-5.17.85 share/rbbt_commands/tsv/unzip
rbbt-util-5.17.84 share/rbbt_commands/tsv/unzip
rbbt-util-5.17.83 share/rbbt_commands/tsv/unzip
rbbt-util-5.17.82 share/rbbt_commands/tsv/unzip
rbbt-util-5.17.81 share/rbbt_commands/tsv/unzip
rbbt-util-5.17.80 share/rbbt_commands/tsv/unzip
rbbt-util-5.17.78 share/rbbt_commands/tsv/unzip
rbbt-util-5.17.77 share/rbbt_commands/tsv/unzip
rbbt-util-5.17.76 share/rbbt_commands/tsv/unzip
rbbt-util-5.17.75 share/rbbt_commands/tsv/unzip
rbbt-util-5.17.74 share/rbbt_commands/tsv/unzip
rbbt-util-5.17.73 share/rbbt_commands/tsv/unzip
rbbt-util-5.17.72 share/rbbt_commands/tsv/unzip
rbbt-util-5.17.71 share/rbbt_commands/tsv/unzip