Returns a CSV alignment table representation of the collation graph, one
row per witness (or witness uncorrected.)
+=head2 as_tsv
+
+Returns a tab-separated alignment table representation of the collation graph,
+one row per witness (or witness uncorrected.)
+
=cut
-sub as_csv {
- my( $self ) = @_;
+sub _tabular {
+ my( $self, $fieldsep ) = @_;
my $table = $self->alignment_table;
- my $csv = Text::CSV->new( { binary => 1, quote_null => 0 } );
+ my $csv = Text::CSV->new( { binary => 1, quote_null => 0, sep_char => $fieldsep } );
my @result;
# Make the header row
$csv->combine( map { $_->{'witness'} } @{$table->{'alignment'}} );
return join( "\n", @result );
}
+sub as_csv {
+ my $self = shift;
+ return $self->_tabular( ',' );
+}
+
+sub as_tsv {
+ my $self = shift;
+ return $self->_tabular( "\t" );
+}
+
=head2 alignment_table
Return a reference to an alignment table, in a slightly enhanced CollateX
help();
}
-unless( $informat =~ /^(CSV|CTE|KUL|Self|TEI|CollateX|tab(ular)?)|xlsx?|db$/i ) {
- help( "Input format must be one of CollateX, CSV, CTE, Self, TEI" );
+unless( $informat =~ /^(CTE|KUL|Self|TEI|CollateX|tab(ular)?)|xlsx?|db$/i ) {
+ help( "Input format must be one of CollateX, CTE, Self, TEI, Tabular, XLS(X), or DB" );
}
my $excel = $informat =~ /^xls/i ? lc( $informat ) : undef;
$informat = 'CollateX' if $informat =~ /^c(ollate)?x$/i;
$informat = 'CollateText' if $informat =~ /^stone$/i;
$informat = 'Tabular' if $informat =~ /^xls/i;
-unless( $outformat =~ /^(graphml|svg|dot|stemma|csv|db)$/ ) {
- help( "Output format must be one of db, graphml, svg, csv, stemma, or dot" );
+unless( $outformat =~ /^(graphml|svg|dot|stemma|(c|t)sv|db)$/ ) {
+ help( "Output format must be one of db, graphml, svg, csv, tsv, stemma, or dot" );
}
if( $from || $to ) {