Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
small changes
  • Loading branch information
Christian Bender committed Jun 30, 2018
commit 1782d3ac48eb990d553604e300cab5d7b7a0bab7
10 changes: 9 additions & 1 deletion core/src/processing/core/PApplet.java
Original file line number Diff line number Diff line change
Expand Up @@ -6121,6 +6121,14 @@ public Table loadTable(String filename) {
}


/**
* Other version with a delimiter
*/
public Table loadTable(String filename, char delimiter) {
return loadTable(filename, null, delimiter);
}


/**
* Options may contain "header", "tsv", "csv", or "bin" separated by commas.
*
Expand Down Expand Up @@ -6163,7 +6171,7 @@ public Table loadTable(String filename, String options) {


/**
* Same method as above inclusive a optiona delimiter.
* Other version with a delimiter
*/
public Table loadTable(String filename, String options, char delimiter) {

Expand Down
18 changes: 16 additions & 2 deletions core/src/processing/data/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ public Table(File file, String options) throws IOException {
extensionOptions(true, file.getName(), options));
}

public Table(File file, String options, char delimiter) throws IOException {
// uses createInput() to handle .gz (and eventually .bz2) files
this.delimiter = delimiter;
init();
parse(PApplet.createInput(file),
extensionOptions(true, file.getName(), options));
}

/**
* @nowebref
*/
Expand All @@ -137,6 +145,12 @@ public Table(InputStream input) throws IOException {
}


public Table(InputStream input, char delimiter) throws IOException {
this(input, null);
this.delimiter = delimiter;
}


/**
* Read the table from a stream. Possible options include:
* <ul>
Expand Down Expand Up @@ -1274,7 +1288,7 @@ protected void writeCSV(PrintWriter writer) {
if (columnTitles != null) {
for (int col = 0; col < getColumnCount(); col++) {
if (col != 0) {
writer.print(',');
writer.print(delimiter);
}
try {
if (columnTitles[col] != null) { // col < columnTitles.length &&
Expand All @@ -1291,7 +1305,7 @@ protected void writeCSV(PrintWriter writer) {
for (int row = 0; row < rowCount; row++) {
for (int col = 0; col < getColumnCount(); col++) {
if (col != 0) {
writer.print(',');
writer.print(delimiter);
}
String entry = getString(row, col);
// just write null entries as blanks, rather than spewing 'null'
Expand Down