-
Notifications
You must be signed in to change notification settings - Fork 0
/
TSVBase.pde
71 lines (55 loc) · 1.29 KB
/
TSVBase.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class TSVBase {
boolean hasHeader;
int rowCount = 0;
int columnCount = 0;
String[] columnNames; // valid if hasHeader
TSVBase(String filename, boolean hasHeader) {
String[] rows = loadStrings(filename); // actually text lines
int i;
columnNames = split(rows[0], TAB);
columnCount = columnNames.length;
if (hasHeader) {
i = 1;
} else {
columnNames = null;
i = 0;
}
allocateData(rows.length-i);
for (; i < rows.length; i++) {
if (trim(rows[i]).length() == 0) {
continue; // skip empty rows
}
if (rows[i].startsWith("#")) {
continue; // skip comment lines
}
String[] pieces = split(rows[i], TAB);
if (createItem(rowCount, pieces)) rowCount++;
}
resizeData(rowCount);
}
void allocateData(int rows)
{
println("UNIMPLEMENTED");
}
boolean createItem(int i, String[] pieces)
{
println("UNIMPLEMENTED");
return false;
}
void resizeData(int rows)
{
println("UNIMPLEMENTED");
}
int getRowCount() {
return rowCount;
}
int getColumnCount() {
return columnCount;
}
String getColumnName(int colIndex) {
return columnNames[colIndex];
}
String[] getColumnNames() {
return columnNames;
}
}