I am fairly new to Java but am trying my best to learn. As a personal experiment I am writing a program that times the film developing process, fairly similar to the 'Massive Dev Chart' for Android and iPhone which I use quite a lot.
Following the code at: https://www.youtube.com/watch?v=QeaXXpxNtq0, I have the following code to read a CSV file and generate a 2 dimensional array:
static String xStrPath;
static String[][] myArray;
static void setUpMyCSVArray() {
myArray = new String[8702][8];
Scanner scanLn = null;
int Rowc = 0;
int Row = 0;
int Colc = 0;
int Col = 0;
String InputLine = "";
double xnum = 0;
String xfileLocation;
xfileLocation = "database.csv";
System.out.println("\n****** Setup Array ******");
try {
scanLn = new Scanner(new BufferedReader(new FileReader(xfileLocation)));
while (scanLn.hasNextLine()) {
InputLine = scanLn.nextLine();
String[] InArray = InputLine.split(",");
for (int x = 0; x < InArray.length; x++) {
myArray [Rowc] [x] = InArray[x];
}
Rowc++;
}
} catch (Exception e) {
System.out.println(e);
}
System.out.println(Arrays.toString(myArray[0]));
}
The CSV file looks like this:
Film Name Developer Dilution ISO/ASA 35mm 120 Sheet Temperature
Adox CHM 125, 510-Pyro, 1+100, 125, 7, , , 21C
Adox CHM 125, 510-Pyro, 1+500, 125, 50, , , 21C
Adox CHM 125, 777, stock, 100, 12, , , 24C
Adox CHM 125, A03, stock, 125, 6.5, , , 20C
Adox CHM 125, ACU-1, 1+10, 100, 9, , , 21C
Adox CHM 125, Acufine, stock, 125, 4, , , 20C
Adox CHM 125, Acufine, stock, 200, 6, , , 20C
Adox CHM 125, Acufine, stock, 320, 5, , , 21C
When I run:
System.out.println(Arrays.toString(myArray[0]));
The output is:
Adox CHM 125, 510-Pyro, 1+100, 125, 7, , , 21C
But I am unable to separate the data on that line, i.e. I want to run
System.out.println(Arrays.toString(myArray[0][0]));
To output:
Adox CHM 125
After many attempts I am a little stuck as to what is going wrong with my code, any help or advice would be much appreciated.