MCPcopy Index your code
hub / github.com/benfry/processing4 / parseBasic

Method parseBasic

core/src/processing/data/Table.java:418–465  ·  view source on GitHub ↗
(BufferedReader reader,
                            boolean header, boolean tsv)

Source from the content-addressed store, hash-verified

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

Callers 1

parseMethod · 0.95

Calls 7

setRowCountMethod · 0.95
getRowCountMethod · 0.95
setColumnTitlesMethod · 0.95
splitMethod · 0.95
splitLineCSVMethod · 0.95
setRowMethod · 0.95
printStackTraceMethod · 0.45

Tested by

no test coverage detected