#!/usr/bin/perl

foreach $n (1..6){
  open(IN,"<data".$n);
  open(OUT,">cryst".$n.".gap");
  print OUT "cryst".$n.":=[\n";
  $nn=<IN>;
  foreach $i (1..$nn){
    $a=<IN>;
    @a=split(/ /,$a);
    $name=$a[0];
    $degree=$a[1];
    $symbol=$a[2];
    $order=$a[3];
    $discr=$a[4];
    open(IN2,"<dim".$degree."/dir.".$symbol."/ordnung.".$order."/".$discr."/".$name);
    $b=<IN2>;
    $ng=substr($b,2);
    foreach $j1 (1..$ng){
      $b=<IN2>;
      if($j1==1){
        print OUT "Group(\n[[";
      } else {
        print OUT " [";
      }
      foreach $j2 (1..$n){
        $b=<IN2>;
        $b =~ s/^ //;
        $b =~ s/[\r\n]//g;
        $b =~ s/ $//;
        $b =~ s/ /,/g;
        print OUT "[".$b."]";
        if($j2<$n){
          print OUT ",";
        } else {
          print OUT "]";
        }
      }
      if($j1<$ng){
        print OUT ",\n";
      } else {
        print OUT "])";
      }
    }
    close (IN2);
    if($i < $nn){
      print OUT ",\n";
    } else {
      print OUT "];\n";
    }
  }
  close(OUT);
  close(IN);
}
