fixed formhandler error
[scpubgit/stemmatology.git] / script / svg_from_csv.pl
CommitLineData
5f5e51a5 1#!/usr/bin/perl
dd3b58b0 2
3use lib 'lib';
4use strict;
5use warnings;
e2902068 6use Text::Tradition;
dd3b58b0 7
5f5e51a5 8# First: read the base. Make a graph, but also note which
9# nodes represent line beginnings.
10
11my $tradition = Text::Tradition->new(
12 'CSV' => $ARGV[0],
13 'base' => $ARGV[1],
15d2d3df 14 'linear' => 0,
5f5e51a5 15 );
16
dd3b58b0 17
1f563ac3 18print $tradition->collation->as_svg();
5f5e51a5 19print STDERR "DONE\n";
20__END__
21my $rows = 0;
22my $matrix = [];
23foreach my $pos ( $collation_graph->{'positions'}->all ) {
24 my @p_nodes = $collation_graph->{'positions'}->nodes_at_position( $pos );
25 $rows = scalar @p_nodes
26 if $rows < scalar @p_nodes;
27 push( @$matrix, \@p_nodes );
28}
29print "<html><head><title>A table</title></head><body><table>\n";
30foreach my $i ( 0 .. $rows-1 ) {
31 print "\t<tr>\n";
32 foreach my $col( @$matrix ) {
33 my $str = '';
34 if( $col->[$i] ) {
35 $str = $collation_graph->node( $col->[$i] )->label;
36 }
37 printf( "\t\t<td>%s</td>\n", $str );
38 }
39 print "\t</tr>\n";
40}
41print "</table></body></html>\n";