Index: trunk/tools/bills/comparestackdetections
===================================================================
--- trunk/tools/bills/comparestackdetections	(revision 39149)
+++ trunk/tools/bills/comparestackdetections	(revision 39150)
@@ -22,5 +22,5 @@
 my $testdata;
 
-my ($checkdeltas, $verbose, $save_temps);
+my ($checkdeltas, $just_join, $verbose, $save_temps);
 
 my $label = 'SAS.20141118.sc8';
@@ -30,4 +30,5 @@
     "testdata=s"        =>  \$testdata,
     "join=s"            =>  \$joinType,
+    "just-join"         =>  \$just_join,
     "check"             =>  \$checkdeltas,
     "verbose|v"         =>  \$verbose,
@@ -90,4 +91,8 @@
     $command .= " --test" if $testdata;
     $command .= " --verbose" if $verbose;
+    # FITS has a limit of 999 for the number of columns in a table
+    # If we're adding the delta columns that's too many. So skip the
+    # joins (we heed to run joinstackcmf to add some columns that we need)
+    $command .= " --skip-joins" unless $just_join;
 
     runcommand($command);
@@ -112,4 +117,10 @@
     $input = $outfile;
 }
+
+if ($just_join) {
+    rename ($outfile, $out) or die "failed to rename $outfile to $out\n";
+    exit 0;
+}
+
 
 my @deltas;
@@ -141,4 +152,14 @@
 
 if ($checkdeltas) {
+    my ($fmt, $sep);
+    if ($out =~ /fits$/) {
+        $fmt = "-fits StackObjectAttributes";
+        $sep = "";
+    } elsif ($out =~ /csv$/) {
+        $fmt = "-csv";
+        $sep = ",";
+    } else {
+        die "don't know how to read $out. Use .fits or .csv\n";
+    }
     $save_temps = 1;
     my ($manafile, $mananame) = tempfile( "/var/tmp/manacmds.XXXX", UNLINK => !$save_temps);
@@ -172,6 +193,12 @@
 
     print $manafile "datafile $out\n";
-    print $manafile "read -fits StackObjectAttributes";
+    print $manafile "read $fmt";
+    my $first = 1;
     foreach my $col (@deltas) {
+        if ($sep and !$first) {
+            print $manafile $sep;
+        } else {
+            $first = 0;
+        }
         print $manafile " $col";
     }
