Hey,
I am making a program that reads data from a radio telescope and then sums the data then plots it.
I am having some problems about reading the data and have some questions.
I at first had it so it was shown as a string. data = x.next();. The output showed everything in the text file. I then changed it into double and seems like its not reading all the numbers. Here's the code i used to read. Is the problem the text file containing the data? It's only numbers. well I attached the txt file data.txt
My other question is how would I go about summing the data? I want to sum each row of data, but the output shows data on each line. Is there a way so the program reads one line and sums the data then reads next line sums that data ect? Or thinking might be easier to have it sum every 20 piece of data, since each row has the same amount of data.
Thinking maybe storing that sum data in hash table or make an array of variables.
while(x.hasNextDouble()){ // if( i <= 17){ // } // if(i >=67){ // } data = x.nextDouble(); // String fa = x.next(); System.out.println(data); } System.out.printf("done"); }
Also I was trying to store the data back into a different text file, but it seems to only store the last number.
try { PrintWriter outputStream = new PrintWriter(file); outputStream.print(data); outputStream.println(""); //outputStream.println("\n" + data); outputStream.flush(); } catch (FileNotFoundException e) { e.printStackTrace(); }