(BufferedReader reader,
boolean header, boolean tsv)
| 402 | |
| 403 | |
| 404 | protected void parseBasic(BufferedReader reader, |
| 405 | boolean header, boolean tsv) throws IOException { |
| 406 | String line = null; |
| 407 | int row = 0; |
| 408 | if (rowCount == 0) { |
| 409 | setRowCount(10); |
| 410 | } |
| 411 | //int prev = 0; //-1; |
| 412 | try { |
| 413 | while ((line = reader.readLine()) != null) { |
| 414 | if (row == getRowCount()) { |
| 415 | setRowCount(row << 1); |
| 416 | } |
| 417 | if (row == 0 && header) { |
| 418 | setColumnTitles(tsv ? PApplet.split(line, '\t') : splitLineCSV(line, reader)); |
| 419 | header = false; |
| 420 | } else { |
| 421 | setRow(row, tsv ? PApplet.split(line, '\t') : splitLineCSV(line, reader)); |
| 422 | row++; |
| 423 | } |
| 424 | |
| 425 | if (row % 10000 == 0) { |
| 426 | /* |
| 427 | // this is problematic unless we're going to calculate rowCount first |
| 428 | if (row < rowCount) { |
| 429 | int pct = (100 * row) / rowCount; |
| 430 | if (pct != prev) { // also prevents "0%" from showing up |
| 431 | System.out.println(pct + "%"); |
| 432 | prev = pct; |
| 433 | } |
| 434 | } |
| 435 | */ |
| 436 | try { |
| 437 | // Sleep this thread so that the GC can catch up |
| 438 | Thread.sleep(10); |
| 439 | } catch (InterruptedException e) { |
| 440 | e.printStackTrace(); |
| 441 | } |
| 442 | } |
| 443 | } |
| 444 | } catch (Exception e) { |
| 445 | throw new RuntimeException("Error reading table on line " + row, e); |
| 446 | } |
| 447 | // shorten or lengthen based on what's left |
| 448 | if (row != getRowCount()) { |
| 449 | setRowCount(row); |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | |
| 454 | // public void convertTSV(BufferedReader reader, File outputFile) throws IOException { |
no test coverage detected