Sha256: 8b571540be8393cf8d53b2fd7a5b8992df413205b2b1d59536e00d67d9b9697d

Contents?: true

Size: 1019 Bytes

Versions: 18

Compression:

Stored size: 1019 Bytes

Contents

#!/usr/bin/env ruby

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

require 'rbbt/util/R'

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

options = SOPT.setup <<EOF
Take absolute value

$ rbbt stat density <file>

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

-tch--tokyocabinet File is a TC HDB
-tcb--tokyocabinet_bd File is a TC BDB
-t--type* Type of tsv (single, list, double, flat)
-h--header_hash* Change the character used to mark the header line (defaults to #)
-f--field Field to change
-h--help Help
EOF

SOPT.usage if options[:help]

file = ARGV.shift

if file == '-' or file.nil?
  file = STDIN 
else
  file = Open.open file
end

parser = TSV::Parser.new file, options

options[:fields] = [options.delete(:field) || 0]
puts TSV.header_lines(parser.key_field, parser.fields)
parser.traverse(options.merge(:type => :list)) do |k,v|
  v = v.first
  v = Array === v ? v.collect{|e| e.to_f.abs } : [v.to_f.abs]
  puts [k,v].flatten * "\t"
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
rbbt-util-5.9.8 share/rbbt_commands/stat/abs
rbbt-util-5.9.7 share/rbbt_commands/stat/abs
rbbt-util-5.9.6 share/rbbt_commands/stat/abs
rbbt-util-5.9.5 share/rbbt_commands/stat/abs
rbbt-util-5.9.4 share/rbbt_commands/stat/abs
rbbt-util-5.9.3 share/rbbt_commands/stat/abs
rbbt-util-5.9.2 share/rbbt_commands/stat/abs
rbbt-util-5.9.1 share/rbbt_commands/stat/abs
rbbt-util-5.9.0 share/rbbt_commands/stat/abs
rbbt-util-5.8.10 share/rbbt_commands/stat/abs
rbbt-util-5.8.9 share/rbbt_commands/stat/abs
rbbt-util-5.8.8 share/rbbt_commands/stat/abs
rbbt-util-5.8.7 share/rbbt_commands/stat/abs
rbbt-util-5.8.6 share/rbbt_commands/stat/abs
rbbt-util-5.8.4 share/rbbt_commands/stat/abs
rbbt-util-5.8.3 share/rbbt_commands/stat/abs
rbbt-util-5.8.2 share/rbbt_commands/stat/abs
rbbt-util-5.8.1 share/rbbt_commands/stat/abs