Skip to content

Commit c001eb2

Browse files
committed
actually fix the category bug, and remove debug lines. ahem.
1 parent 3230784 commit c001eb2

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

core/src/processing/data/Table.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,7 @@ public void setColumnType(int column, int newType) {
15031503
int[] intData = new int[rowCount];
15041504
for (int row = 0; row < rowCount; row++) {
15051505
String s = getString(row, column);
1506-
intData[row] = PApplet.parseInt(s, missingInt);
1506+
intData[row] = (s == null) ? missingInt : PApplet.parseInt(s, missingInt);
15071507
}
15081508
columns[column] = intData;
15091509
break;
@@ -1513,7 +1513,7 @@ public void setColumnType(int column, int newType) {
15131513
for (int row = 0; row < rowCount; row++) {
15141514
String s = getString(row, column);
15151515
try {
1516-
longData[row] = Long.parseLong(s);
1516+
longData[row] = (s == null) ? missingLong : Long.parseLong(s);
15171517
} catch (NumberFormatException nfe) {
15181518
longData[row] = missingLong;
15191519
}
@@ -1525,7 +1525,7 @@ public void setColumnType(int column, int newType) {
15251525
float[] floatData = new float[rowCount];
15261526
for (int row = 0; row < rowCount; row++) {
15271527
String s = getString(row, column);
1528-
floatData[row] = PApplet.parseFloat(s, missingFloat);
1528+
floatData[row] = (s == null) ? missingFloat : PApplet.parseFloat(s, missingFloat);
15291529
}
15301530
columns[column] = floatData;
15311531
break;
@@ -1535,7 +1535,7 @@ public void setColumnType(int column, int newType) {
15351535
for (int row = 0; row < rowCount; row++) {
15361536
String s = getString(row, column);
15371537
try {
1538-
doubleData[row] = Double.parseDouble(s);
1538+
doubleData[row] = (s == null) ? missingDouble : Double.parseDouble(s);
15391539
} catch (NumberFormatException nfe) {
15401540
doubleData[row] = missingDouble;
15411541
}
@@ -1861,7 +1861,7 @@ public TableRow addRow(TableRow source) {
18611861
case CATEGORY:
18621862
int index = source.getInt(col);
18631863
setInt(row, col, index);
1864-
if (columnCategories[col].hasCategory(index)) {
1864+
if (!columnCategories[col].hasCategory(index)) {
18651865
columnCategories[col].setCategory(index, source.getString(col));
18661866
}
18671867
break;
@@ -3659,11 +3659,11 @@ private void writeln(PrintWriter writer) throws IOException {
36593659

36603660
void read(DataInputStream input) throws IOException {
36613661
int count = input.readInt();
3662-
System.out.println("found " + count + " entries in category map");
3662+
//System.out.println("found " + count + " entries in category map");
36633663
dataToIndex = new HashMap<String, Integer>(count);
36643664
for (int i = 0; i < count; i++) {
36653665
String str = input.readUTF();
3666-
System.out.println(i + " " + str);
3666+
//System.out.println(i + " " + str);
36673667
dataToIndex.put(str, i);
36683668
indexToData.add(str);
36693669
}

core/todo.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ X add getColumnTitle(int) and getColumnTitles() to TableRow interface
1515
X fixes for new Table(Iterable)
1616
X category data types were not importing their dictionary
1717
X column titles weren't set on the new table
18+
X when using setColumnType(), replace nulls with missingInt, missingFloat, etc
19+
X formerly, was throwing a NullPointerException
1820

1921

2022
applet removal

0 commit comments

Comments
 (0)