Sha256: 0d98fa59179820236c3cca372e09cb9e5c797fd445ea4af545a853de4c604cae

Contents?: true

Size: 1.12 KB

Versions: 527

Compression:

Stored size: 1.12 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 #)
-zs--zip_sep* Separator between zipped fields
-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
zs = options[:zip_sep] || ":"

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, zs).to_s

Version data entries

527 entries across 527 versions & 1 rubygems

Version Path
rbbt-util-5.33.17 share/rbbt_commands/tsv/unzip
rbbt-util-5.33.16 share/rbbt_commands/tsv/unzip
rbbt-util-5.33.15 share/rbbt_commands/tsv/unzip
rbbt-util-5.33.14 share/rbbt_commands/tsv/unzip
rbbt-util-5.33.13 share/rbbt_commands/tsv/unzip
rbbt-util-5.33.12 share/rbbt_commands/tsv/unzip
rbbt-util-5.33.11 share/rbbt_commands/tsv/unzip
rbbt-util-5.33.9 share/rbbt_commands/tsv/unzip
rbbt-util-5.33.8 share/rbbt_commands/tsv/unzip
rbbt-util-5.33.7 share/rbbt_commands/tsv/unzip
rbbt-util-5.33.6 share/rbbt_commands/tsv/unzip
rbbt-util-5.33.5 share/rbbt_commands/tsv/unzip
rbbt-util-5.33.4 share/rbbt_commands/tsv/unzip
rbbt-util-5.33.3 share/rbbt_commands/tsv/unzip
rbbt-util-5.33.2 share/rbbt_commands/tsv/unzip
rbbt-util-5.33.1 share/rbbt_commands/tsv/unzip
rbbt-util-5.33.0 share/rbbt_commands/tsv/unzip
rbbt-util-5.32.30 share/rbbt_commands/tsv/unzip
rbbt-util-5.32.28 share/rbbt_commands/tsv/unzip
rbbt-util-5.32.27 share/rbbt_commands/tsv/unzip