Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Header handling for chained files

  • Loading branch information...
commit e1865d0176b4780053a150dbbc3121aee756c91b 1 parent 874990e
@pjotrp authored
Showing with 14 additions and 4 deletions.
  1. +8 −1 README.md
  2. +4 −2 bin/bio-table
  3. +2 −1  lib/bio-table/table_apply.rb
View
9 README.md
@@ -247,7 +247,14 @@ You can combine/concat two or more tables by passing in multiple file names
```
this will append table2 to table1, assuming they have the same headers
-(you can use the --columns switch!)
+(you can use the --columns switch at the same time!). With --skip
+the header lines are skipped in every file. This can be a real asset
+when using the Unix split command on input files and combining output
+files again. Something this might work:
+
+```sh
+ ls run/*.out -1|sort|xargs bio-table --skip 3
+```
To combine tables side by side use the --merge switch:
View
6 bin/bio-table
@@ -183,7 +183,7 @@ end
Bio::Log::CLI.configure('bio-table')
logger = Bio::Log::LoggerPlus['bio-table']
-logger.info [options, ARGV]
+logger.info [options]
include BioTable
@@ -233,10 +233,12 @@ writer =
if INPUT_ON_STDIN
opts = options.dup # so we can 'safely' modify options
+ has_input = false
BioTable::TableLoader.emit(STDIN, opts).each do |row, type|
writer.write(TableRow.new(row[0],row[1..-1]),type)
+ has_input = true
end
- options[:write_header] = false # don't write the header for chained files
+ options[:write_header] = false if has_input # don't write the header for chained files
end
statistics = if options[:statistics]
View
3  lib/bio-table/table_apply.rb
@@ -29,6 +29,7 @@ def initialize options
@include_rownames = options[:with_rownames]
@logger.debug "Include row names" if @include_rownames
@first_column = (@include_rownames ? 0 : 1)
+ @write_header = options[:write_header]
end
def parse_header(line, options)
@@ -39,7 +40,7 @@ def parse_header(line, options)
if options[:unshift_headers]
header.unshift("ID")
end
- @logger.info(header) if @logger
+ @logger.info(header) if @logger and @write_header
header
end
Please sign in to comment.
Something went wrong with that request. Please try again.