1
0
Fork 0

//implemented readCsv

main
emelie 2024-01-08 21:52:47 +01:00
parent 701302e3cd
commit 576bdc8821
1 changed files with 19 additions and 19 deletions

View File

@ -95,44 +95,44 @@ public class Spreadsheet {
ArrayList<String> fileRows = new ArrayList<>(); ArrayList<String> fileRows = new ArrayList<>();
Scanner sc = new Scanner(new File(filePath)); Scanner sc = new Scanner(new File(filePath));
/* while (sc.hasNextLine()) { while (sc.hasNextLine()) {
fileRows.add(sc.nextLine()); fileRows.add(sc.nextLine());
} }
ArrayList <int[]> formulas = new ArrayList<>(); ArrayList <int[]> formulas = new ArrayList<>();
for (int rowI = 0; rowI < fileRows.size(); rowI++) { for (int r = 0; r < fileRows.size(); r++) {
String row = fileRows.get(rowI); String row = fileRows.get(r);
String[] cells = row.split(separator); String[] cells = row.split(separator);
for (int colI = 0; colI < cells.length; colI++) { for (int c = 0; c < cells.length; c++) {
String cellContent = cells[colI].toUpperCase(); String cellFill = cells[c].toUpperCase();
if (cellContent.startsWith("=")){ if (cellFill.startsWith("=")){
formulas.add(new int[]{rowI, colI}); formulas.add(new int[]{r, c});
} }
else { else {
put(rowI, colI, cellContent); put(r, c, cellFill);
} }
} }
} }
for (int[] formulaPos : formulas){ for (int[] formulaAt : formulas){
int rowI = formulaPos[0]; int r = formulaAt[0];
int colI = formulaPos[1]; int c = formulaAt[1];
System.out.printf("Formula at %d-%d %n", rowI, colI); System.out.printf("Formula at %d-%d %n", r, c);
String row = fileRows.get(rowI); String row = fileRows.get(r);
String formulaToFill = row.split(separator)[colI]; String formulaToFill = row.split(separator)[c];
put(rowI, colI, formulaToFill); put(r, c, formulaToFill);
} }
sc.close(); sc.close();
*/
} }
@ -306,7 +306,7 @@ public class Spreadsheet {
/** /**
* Method for calculating the minimum of a rectangular block of cells * Method for calculating the minimum of a rectangular block of cells
* @param startCellName The name of the cell in the upper left corner of the rectangle. * @param startCellName The name of the cell in the upper left corner of the rectangle.
* @param endCellName The name of the cell in the lower right corner ofODO the rectangle. * @param endCellName The name of the cell in the lower right corner of the rectangle.
* @return The minimum. * @return The minimum.
*/ */
@ -345,7 +345,7 @@ public class Spreadsheet {
/** /**
* Method for calculating the maximum of a rectangular block of cells * Method for calculating the maximum of a rectangular block of cells
* @param startCellName The name of the cell in the upper left corner of the rectangle. * @param startCellName The name of the cell in the upper left corner of the rectangle.
* @param endCellName The name of the cell in the lower right corner ofODO the rectangle. * @param endCellName The name of the cell in the lower right corner of the the rectangle.
* @return The maximum. * @return The maximum.
*/ */
@ -382,7 +382,7 @@ public class Spreadsheet {
/** /**
* Method for calculating the standard deviation of a rectangular block of cells * Method for calculating the standard deviation of a rectangular block of cells
* @param startCellName The name of the cell in the upper left corner of the rectangle. * @param startCellName The name of the cell in the upper left corner of the rectangle.
* @param endCellName The name of the cell in the lower right corner ofODO the rectangle. * @param endCellName The name of the cell in the lower right corner of the the rectangle.
* @return The standard deviation calculated. * @return The standard deviation calculated.
*/ */