public int lastRowIndex() { return getRowCount() - 1; }
@Override public int size() { return getRowCount(); }
public boolean hasNext() { return row+1 < table.getRowCount(); }
public int lastRowIndex() { return getRowCount() - 1; }
@Override public int size() { return getRowCount(); }
public boolean hasNext() { return row+1 < table.getRowCount(); }
public void addRows(Table source) { int index = getRowCount(); setRowCount(index + source.getRowCount()); for (TableRow row : source.rows()) { setRow(index++, row); } }
protected void writeHTML(PrintWriter writer) { writer.println("<html>"); writer.println("<head>"); writer.println(" <meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\" />"); writer.println("</head>"); writer.println("<body>"); writer.println(" <table>"); for (int row = 0; row < getRowCount(); row++) { writer.println(" <tr>"); for (int col = 0; col < getColumnCount(); col++) { String entry = getString(row, col); writer.print(" <td>"); writeEntryHTML(writer, entry); writer.println(" </td>"); } writer.println(" </tr>"); } writer.println(" </table>"); writer.println("</body>"); writer.println("</hmtl>"); writer.flush(); }
/** * @nowebref */ public TableRow addRow(Object[] columnData) { setRow(getRowCount(), columnData); return new RowPointer(this, rowCount - 1); }
/** * @nowebref */ public TableRow addRow(Object[] columnData) { setRow(getRowCount(), columnData); return new RowPointer(this, rowCount - 1); }
public void setColumnTypes(final Table dictionary) { ensureColumn(dictionary.getRowCount() - 1); int typeCol = 1; final String[] typeNames = dictionary.getStringColumn(typeCol); if (dictionary.getColumnCount() > 1) { if (getRowCount() > 1000) { int proc = Runtime.getRuntime().availableProcessors(); ExecutorService pool = Executors.newFixedThreadPool(proc/2); for (int i = 0; i < dictionary.getRowCount(); i++) { final int col = i; pool.execute(new Runnable() { public void run() { setColumnType(col, typeNames[col]); } }); } pool.shutdown(); while (!pool.isTerminated()) { Thread.yield(); } } else { for (int col = 0; col < dictionary.getRowCount(); col++) { setColumnType(col, typeNames[col]); } } } }
/** * Searches the entire table for float values. * Returns missing float (Float.NaN by default) if no valid numbers found. */ protected float getMaxFloat() { boolean found = false; float max = PConstants.MIN_FLOAT; for (int row = 0; row < getRowCount(); row++) { for (int col = 0; col < getColumnCount(); col++) { float value = getFloat(row, col); if (!Float.isNaN(value)) { // TODO no, this should be comparing to the missing value if (!found) { max = value; found = true; } else if (value > max) { max = value; } } } } return found ? max : missingFloat; }
/** * Searches the entire table for float values. * Returns missing float (Float.NaN by default) if no valid numbers found. */ protected float getMaxFloat() { boolean found = false; float max = PConstants.MIN_FLOAT; for (int row = 0; row < getRowCount(); row++) { for (int col = 0; col < getColumnCount(); col++) { float value = getFloat(row, col); if (!Float.isNaN(value)) { // TODO no, this should be comparing to the missing value if (!found) { max = value; found = true; } else if (value > max) { max = value; } } } } return found ? max : missingFloat; }
/** * Return a mapping that connects the entry from a column back to the row * from which it came. For instance: * <pre> * Table t = loadTable("country-data.tsv", "header"); * // use the contents of the 'country' column to index the table * Map<String, TableRow> lookup = t.getRowMap("country"); * // get the row that has "us" in the "country" column: * TableRow usRow = lookup.get("us"); * // get an entry from the 'population' column * int population = usRow.getInt("population"); * </pre> */ public Map<String, TableRow> getRowMap(int column) { Map<String, TableRow> outgoing = new HashMap<>(); for (int row = 0; row < getRowCount(); row++) { String id = getString(row, column); outgoing.put(id, new RowPointer(this, row)); } // for (TableRow row : rows()) { // String id = row.getString(column); // outgoing.put(id, row); // } return outgoing; }
for (int row = 0; row < getRowCount(); row++) { writer.println(" <tr>"); for (int col = 0; col < getColumnCount(); col++) {
ensureColumn(dictionary.getRowCount() - 1); int titleCol = 0; int typeCol = 1; if (getRowCount() > 1000) { int proc = Runtime.getRuntime().availableProcessors(); ExecutorService pool = Executors.newFixedThreadPool(proc/2); for (int i = 0; i < dictionary.getRowCount(); i++) { final int col = i; pool.execute(new Runnable() { for (int col = 0; col < dictionary.getRowCount(); col++) {
if (getRowCount() > 1000) { int proc = Runtime.getRuntime().availableProcessors(); ExecutorService pool = Executors.newFixedThreadPool(proc/2); for (int i = 0; i < dictionary.getRowCount(); i++) { final int col = i; pool.execute(new Runnable() { for (int col = 0; col < dictionary.getRowCount(); col++) {
static protected boolean isDateColumn(Table table, int i, String missing) { if (table.getColumnType(i) == Table.STRING || table.getColumnType(i) == Table.CATEGORY) { int totCount = 0; int dateCount = 0; for (int n = 0; n < table.getRowCount(); n++) { TableRow row = table.getRow(n); String value = row.getString(i); if (value == null || value.equals(missing)) continue; if (supportedDateString(value)) dateCount++; totCount++; if (totCount == 10) break; } float frac = (float)dateCount / (float)totCount; return 0.5f < frac; } else { return false; } }
if (row == getRowCount()) { setRowCount(row << 1); if (row != getRowCount()) { setRowCount(row);
while (getRowCount() > 0 && isEmptyArray(getStringRow(0))) { removeRow(0);