Sha256: 768d9b311ea1afbccf71ab664fa61138cb7c3622321fe2895368010ab20f4fdb

Contents?: true

Size: 1.14 KB

Versions: 13

Compression:

Stored size: 1.14 KB

Contents

#!/usr/bin/env ruby

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

options = SOPT.get("-tch--tokyocabinet:-tcb--tokyocabinet_bd:-t--type*:-h--header_hash*:-k--key_field*:-f--fields*")

options[:fields] = options[:fields].split(/,\|/) if options[:fields]
options[:header_hash] = options["header_hash"]

file = ARGV.shift

file = STDIN if file == '-'

raise ParameterException, "Please specify the tsv file as argument" if file.nil?

case
when options[:tokyocabinet]
  tsv = Persist.open_tokyocabinet(file, false)
  puts tsv.summary
when options[:tokyocabinet_bd]
  tsv = Persist.open_tokyocabinet(file, false, nil, TokyoCabinet::BDB)
  puts tsv.summary
else
  header = TSV.parse_header(Open.open(file), options)

  puts "File: #{ file }"
  puts "Type: #{header.type}"
  puts "Key: #{header.key_field}"
  puts "Fields: "
  if header.fields.nil?
  else
    header.fields.each_with_index do |f,i|
      puts "  - #{i + 1}: " << f
    end
  end
  puts "Rows: #{`wc -l #{ file }|cut -f 1 -d' '`}" unless Open.remote? file
  puts "First line:"
  parts = []
  header.first_line.split(header.sep).each_with_index{|p,i| parts << "(#{i}) #{p}"}
  puts parts * "\t"
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rbbt-util-5.7.0 share/rbbt_commands/tsv/info
rbbt-util-5.6.17 share/rbbt_commands/tsv/info
rbbt-util-5.6.16 share/rbbt_commands/tsv/info
rbbt-util-5.6.15 share/rbbt_commands/tsv/info
rbbt-util-5.6.14 share/rbbt_commands/tsv/info
rbbt-util-5.6.13 share/rbbt_commands/tsv/info
rbbt-util-5.6.12 share/rbbt_commands/tsv/info
rbbt-util-5.6.11 share/rbbt_commands/tsv/info
rbbt-util-5.6.10 share/rbbt_commands/tsv/info
rbbt-util-5.6.9 share/rbbt_commands/tsv/info
rbbt-util-5.6.8 share/rbbt_commands/tsv/info
rbbt-util-5.6.7 share/rbbt_commands/tsv/info
rbbt-util-5.6.6 share/rbbt_commands/tsv/info