1
0
Fork 0

Compare commits

...

2 Commits

Author SHA1 Message Date
Emelie Schneider aac8541abe //implemented readCsv 2024-01-08 21:55:08 +01:00
emelie 576bdc8821 //implemented readCsv 2024-01-08 21:52:47 +01:00
1 changed files with 19 additions and 20 deletions

View File

@ -95,44 +95,43 @@ public class Spreadsheet {
ArrayList<String> fileRows = new ArrayList<>();
Scanner sc = new Scanner(new File(filePath));
/* while (sc.hasNextLine()) {
while (sc.hasNextLine()) {
fileRows.add(sc.nextLine());
}
ArrayList <int[]> formulas = new ArrayList<>();
for (int rowI = 0; rowI < fileRows.size(); rowI++) {
String row = fileRows.get(rowI);
for (int r = 0; r < fileRows.size(); r++) {
String row = fileRows.get(r);
String[] cells = row.split(separator);
for (int colI = 0; colI < cells.length; colI++) {
String cellContent = cells[colI].toUpperCase();
for (int c = 0; c < cells.length; c++) {
String cellFill = cells[c].toUpperCase();
if (cellContent.startsWith("=")){
formulas.add(new int[]{rowI, colI});
if (cellFill.startsWith("=")){
formulas.add(new int[]{r, c});
}
else {
put(rowI, colI, cellContent);
put(r, c, cellFill);
}
}
}
for (int[] formulaPos : formulas){
int rowI = formulaPos[0];
int colI = formulaPos[1];
System.out.printf("Formula at %d-%d %n", rowI, colI);
for (int[] formulaAt : formulas){
int r = formulaAt[0];
int c = formulaAt[1];
System.out.printf("Formula at %d-%d %n", r, c);
String row = fileRows.get(rowI);
String formulaToFill = row.split(separator)[colI];
String row = fileRows.get(r);
String formulaToFill = row.split(separator)[c];
put(rowI, colI, formulaToFill);
put(r, c, formulaToFill);
}
sc.close();
*/
}
@ -306,7 +305,7 @@ public class Spreadsheet {
/**
* 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 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.
*/
@ -345,7 +344,7 @@ public class Spreadsheet {
/**
* 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 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.
*/
@ -382,7 +381,7 @@ public class Spreadsheet {
/**
* 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 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.
*/