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

Method parse

core/src/processing/data/Table.java:341–415  ·  view source on GitHub ↗
(InputStream input, String options)

Source from the content-addressed store, hash-verified

339
340
341 protected void parse(InputStream input, String options) throws IOException {
342// boolean awfulCSV = false;
343 boolean header = false;
344 String extension = null;
345 boolean binary = false;
346 String encoding = "UTF-8";
347
348 String worksheet = null;
349 final String sheetParam = "worksheet=";
350
351 String[] opts = null;
352 if (options != null) {
353 opts = PApplet.trim(PApplet.split(options, ','));
354 for (String opt : opts) {
355 if (opt.equals("tsv")) {
356 extension = "tsv";
357 } else if (opt.equals("csv")) {
358 extension = "csv";
359 } else if (opt.equals("ods")) {
360 extension = "ods";
361 } else if (opt.equals("newlines")) {
362 //awfulCSV = true;
363 //extension = "csv";
364 throw new IllegalArgumentException("The 'newlines' option is no longer necessary.");
365 } else if (opt.equals("bin")) {
366 binary = true;
367 extension = "bin";
368 } else if (opt.equals("header")) {
369 header = true;
370 } else if (opt.startsWith(sheetParam)) {
371 worksheet = opt.substring(sheetParam.length());
372 } else if (opt.startsWith("dictionary=")) {
373 // ignore option, this is only handled by PApplet
374 } else if (opt.startsWith("encoding=")) {
375 encoding = opt.substring(9);
376 } else {
377 throw new IllegalArgumentException("'" + opt + "' is not a valid option for loading a Table");
378 }
379 }
380 }
381
382 if (extension == null) {
383 throw new IllegalArgumentException("No extension specified for this Table");
384 }
385
386 if (binary) {
387 loadBinary(input);
388
389 } else if (extension.equals("ods")) {
390 odsParse(input, worksheet, header);
391
392 } else {
393 InputStreamReader isr = new InputStreamReader(input, encoding);
394 BufferedReader reader = new BufferedReader(isr);
395
396 // strip out the Unicode BOM, if present
397 reader.mark(1);
398 int c = reader.read();

Callers 2

TableMethod · 0.95
typedParseMethod · 0.95

Calls 8

trimMethod · 0.95
splitMethod · 0.95
loadBinaryMethod · 0.95
odsParseMethod · 0.95
parseBasicMethod · 0.95
resetMethod · 0.65
equalsMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected