diff --git a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java index a3bf4ab..d48fa56 100644 --- a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java +++ b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java @@ -1,6 +1,5 @@ package de.hs_mannheim.informatik.spreadsheet; -import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintWriter; @@ -17,18 +16,8 @@ public class Axel { Spreadsheet spr = new Spreadsheet(10,6); @SuppressWarnings("resource") Scanner input = new Scanner(System.in); - - spr.put("A3", "123"); - - spr.put("B9", "=41+A2+10-2/3"); - spr.put("B8", "200"); - spr.put("B7", "200"); - spr.put("B6", "5"); - spr.put("B5", "5"); - spr.put("B4", "24"); - spr.put("B3", "24"); - spr.put("B2", "28"); - spr.put("B1", "24"); + String filePath = "Axel/resources/zahlen.csv"; + spr.readCsv(filePath,"A3"); System.out.println("Schreibe 'stop' zum anhalten."); @@ -63,8 +52,6 @@ public class Axel { } }while(true); - String filePath = "Axel/resources/zahlen.csv"; - try (PrintWriter writer = new PrintWriter(new FileOutputStream(filePath))) { spr.saveCsv(writer); System.out.println("CSV file saved successfully."); diff --git a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java index 8c8dbac..bb09fb5 100644 --- a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java +++ b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java @@ -1,5 +1,6 @@ package de.hs_mannheim.informatik.spreadsheet; +import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintWriter; @@ -7,6 +8,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.ArrayList; import java.util.List; +import java.util.Scanner; /** @@ -86,13 +88,34 @@ public class Spreadsheet { /** * A method for reading in data from a CSV file. * @param path The file to read. - * @param separator The char used to split up the input, e.g. a comma or a semicolon. - * @param starCellName The upper left cell where data from the CSV file should be inserted. + * @param startCellName The upper left cell where data from the CSV file should be inserted. * @return Nothing. * @exception IOException If path does not exist. */ - public void readCsv(String path, char separator, String startCellName) throws FileNotFoundException { - // TODO: implement this + public void readCsv(String path, String startCellName) throws FileNotFoundException { + Scanner csvIn = new Scanner(new File(path)); + int index= 0; + + while(csvIn.hasNextLine()){ + String line =csvIn.nextLine(); + String all=""; + int filled=0; + for(int i = 0;i