Question: How would I write a java program that reads a csv file, called file1.csv. There are 22 lines of data in the file, each line
How would I write a java program that reads a csv file, called file1.csv. There are 22 lines of data in the file, each line having exactly 4776 points of data. The first line says either "DP" or "CR"
The third line is the patients ID (1-21).
The rest of it is doubles.
There is also a file2.csv with the same format that I'm trying to figure out how to read, and add, all the data from it to file1.csv
So it needs to iterator through a csv file through that many commas and take those entries per patients, output in the string tostring the patient id, CR or DP, the 3697 and 3258th piece of data. Also, if there is a
If possible, could you include a tester class to show how to implement it? I'd like to be able to debug it and go through it one step at a time to see how it works.
import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList;
public interface PatientCollectionADT {
// TODO Auto-generated method stub public Patient getPatient (String id) throws IOException;
// Return the patient with the given id. Return void if the id does
// not exist in the collection
public Patient removePatient (String id) throws IOException;
// Remove and return the Patient with the given id. Return void if the id does not exist.
public void setResultForPatient (String id, String result) throws IOException;
// Set the result field for the patient with given id.
public ArrayList
// Return an ArrayList with all of the collection's patient ids
public String addPatientsFromFile (String fileName) throws FileNotFoundException, IOException;
// Method reads all lines from comma separated file named fileName.
// Each line must contain a unique patient identifier followed by exactly 4776 doubles.
// If the line does not meet the criteria, it is not added to the patient collection,
// and an error message is included in the return String.
// The error message will indicate which line was in error and what the error was.
// expected line format
//id,protein1,protein2, ... , protein4776
public String toString ();
// Return a String representation of the collection.
// Only include the 3697th and 3258th values in that order. }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
