Sha256: 8ea96c6d756c835278202ad87da312c24657fd43d766ccfcfec7875c2ca6369a

Contents?: true

Size: 1.49 KB

Versions: 6

Compression:

Stored size: 1.49 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

Write a Excel file with the contents of a TSV

$ rbbt tsv write_excel [options] <filename.tsv|-> [<filename.xls|filename.xlsx>]

If no target file is specified it uses the same input files but replaces extension. Specifying
the extension of the excel file select the excel format to use.

-k--key_field* Key field
-f--fields* Fields
-t--type* Type
-m--merge Merge from multiple rows
-um--unmerge Write the results unmerged
-W--workflows* Load a list of workflows
-R--requires* Require a list of files
-n--name Transform entities to human readible names
-h--help Print this help

EOF
if options[:help]
  if defined? rbbt_usage
    rbbt_usage 
  else
    puts SOPT.doc
  end
  exit 0
end

if options[:workflows]
  require 'rbbt/workflow'
  workflows = options[:workflows].split(',')
  workflows.each do |workflow|
    workflow.strip!
    Workflow.require_workflow workflow
  end
end

if options[:requires]
  requires = options[:requires].split(',')
  requires.each do |req|
    req.strip!
    require req
  end
end

tsvfile, excelfile = ARGV

excelfile, tsvfile = tsvfile, nil if excelfile.nil? and tsvfile =~ /\.(xls|xlsx)$/

raise ParameterException, "No TSV file given" if tsvfile.nil?

excelfile = tsvfile.sub(/\.tsv(\.gz)?$/, '.xlsx') if excelfile.nil?

require 'rbbt/tsv/excel'
TSV.open(tsvfile, options).excel(excelfile, options)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rbbt-util-5.44.1 share/rbbt_commands/tsv/write_excel
rbbt-util-5.43.0 share/rbbt_commands/tsv/write_excel
rbbt-util-5.42.0 share/rbbt_commands/tsv/write_excel
rbbt-util-5.41.1 share/rbbt_commands/tsv/write_excel
rbbt-util-5.41.0 share/rbbt_commands/tsv/write_excel
rbbt-util-5.40.5 share/rbbt_commands/tsv/write_excel