0

For example, I'm parsing data from an excel sheet to a java project in Eclipse. I'll eventually pass this into a DB of some description but I'm using a system.out.println statement, for now, to see how much of the file is being parsed. This is where my confusion lies, there are 36,616 rows in the excel sheet but the parsing code I'm using only parses from position 33,269 to 36,616, as opposed to 1 to 33,616. I'm confused is this an issue with the parsing code or is it too many rows for the console to handle?

My Parser

public class ExcelReader {

    public static final String SAMPLE_XLSX_FILE_PATH = "./LatLongPrice.xlsx";

    public static void main(String[] args) throws IOException, InvalidFormatException {

        Workbook workbook = WorkbookFactory.create(new File(SAMPLE_XLSX_FILE_PATH));

        // Retrieving the number of sheets in the Workbook
        System.out.println("Workbook has " + workbook.getNumberOfSheets() + " Sheets : ");




        // obtain a sheetIterator and iterate over it
        Iterator<Sheet> sheetIterator = workbook.sheetIterator();
        System.out.println("Retrieving Sheets using Iterator");
        while (sheetIterator.hasNext()) {
            Sheet sheet = sheetIterator.next();
            System.out.println("=> " + sheet.getSheetName());
        }



        // Getting the Sheet at index zero
        Sheet sheet = workbook.getSheetAt(0);

        // Create a DataFormatter to format and get each cell's value as String
        DataFormatter dataFormatter = new DataFormatter();

        // Obtain a rowIterator and columnIterator and iterate over them
        System.out.println("\n\nIterating over Rows and Columns using Iterator\n");
        Iterator<Row> rowIterator = sheet.rowIterator();
        while (rowIterator.hasNext()) {
            Row row = rowIterator.next();

            // Iteratating over the columns of the current row
           Iterator<Cell> cellIterator = row.cellIterator();

            while (cellIterator.hasNext()) {
                Cell cell = cellIterator.next();
                String cellValue = dataFormatter.formatCellValue(cell);
                System.out.print(cellValue + "\t");
            }
            System.out.println();
        }
        });

        // Closing the workbook
        workbook.close();
    }
Charles
  • 69
  • 11
  • 1
    Also better write the result into a file instead of printing it on `System.out`. –  Jan 19 '18 at 10:23
  • You specify the max size of the console, or unlimited, in the eclipse settings dialog. Just search for “console” – Erwin Bolwidt Jan 19 '18 at 10:25
  • There is the configurable limit @devpuh said. But I would leave it at that, as everything seems okay. Otherwise **patience** is the limit, as the eclipse needs to store all. Should there be a need, use a Logger, with a file appender and a console appender, so you have both options: a short list in the eclipse console and all in a log. – Joop Eggen Jan 19 '18 at 10:25
  • I understand how this question might be seen as a duplicate but if it was a case of the console running out of space wouldn't the parser start out at the 1st position and run out of space at the 3,347th row as opposed to randomly starting on the 33,269th and parsing through to the end, the 36,616th position (33269-36616 = 3347). – Charles Jan 19 '18 at 10:33
  • 2
    The eclipse console only shows the latest characters. So when you output some text and the buffer is full it drops the oldest values. –  Jan 19 '18 at 10:45
  • That makes sense, so it was just an issue with the console limit as opposed to my parser code. Therefore this is a duplicate. Thank you @devpuh – Charles Jan 19 '18 at 10:59

0 Answers0