package nl.fifth.postulate.bin;

import nom.tam.fits.BinaryTableHDU;
import nom.tam.fits.Fits;
import nom.tam.fits.FitsException;

import java.io.IOException;

public class ToCSV {
    public static void main(String[] args) throws FitsException, IOException {
        String filename = args[0];
        Fits f = new Fits(filename);
        BinaryTableHDU hdu = (BinaryTableHDU) f.getHDU(1);
        double[] time = (double[]) hdu.getColumn("TIME");
        float[][][] rows = (float[][][]) hdu.getColumn("FLUX");

        for (int row = 0, rowLimit = rows.length; row < rowLimit; row++ ) {
            System.out.printf("%f", time[row]);
            float[][] inputImage = rows[row];
            for (int y = 0, ylimit = inputImage.length; y < ylimit; y++) {
                for (int x = 0, xlimit = inputImage[0].length; x < xlimit; x++) {
                    float value = inputImage[y][x];
                    System.out.printf(",%f", value);
                }
            }
            System.out.println();
        }

    }
}

@@ -151,16 +151,44 @@
 ception;
+%0Aimport java.io.PrintStream;
 %0A%0Apublic
@@ -615,39 +615,93 @@
 ) %7B%0A            
-System.
+PrintStream out = new PrintStream(%22output.csv%22);%0A            
 out.printf(%22%25f%22,
@@ -980,39 +980,32 @@
                 
-System.
 out.printf(%22,%25f%22
@@ -1038,32 +1038,32 @@
 %7D%0A            %7D%0A
+
             Syst
@@ -1062,15 +1062,8 @@
     
-System.
 out.

Output CSV to a file