public int getColumnCount() { return table.getColumnCount(); }
public int getColumnCount() { return table.getColumnCount(); }
/** * Set the entire table to a specific data type. */ public void setTableType(String type) { for (int col = 0; col < getColumnCount(); col++) { setColumnType(col, type); } }
/** * @webref table:method * @brief Trims whitespace from values * @see Table#removeTokens(String) */ public void trim() { for (int col = 0; col < getColumnCount(); col++) { trim(col); } }
public void setColumnTitle(int column, String title) { ensureColumn(column); if (columnTitles == null) { columnTitles = new String[getColumnCount()]; } columnTitles[column] = title; columnIndices = null; // reset these fellas }
public void setColumnTitle(int column, String title) { ensureColumn(column); if (columnTitles == null) { columnTitles = new String[getColumnCount()]; } columnTitles[column] = title; columnIndices = null; // reset these fellas }
/** * Set the entire table to a specific data type. */ public void setTableType(String type) { for (int col = 0; col < getColumnCount(); col++) { setColumnType(col, type); } }
/** * Remove any of the specified characters from the entire table. * * @webref table:method * @brief Removes characters from the table * @param tokens a list of individual characters to be removed * @see Table#trim() */ public void removeTokens(String tokens) { for (int col = 0; col < getColumnCount(); col++) { removeTokens(tokens, col); } }
/** * Remove any of the specified characters from the entire table. * * @webref table:method * @brief Removes characters from the table * @param tokens a list of individual characters to be removed * @see Table#trim() */ public void removeTokens(String tokens) { for (int col = 0; col < getColumnCount(); col++) { removeTokens(tokens, col); } }
protected void writeTSV(PrintWriter writer) { if (columnTitles != null) { for (int col = 0; col < columns.length; col++) { if (col != 0) { writer.print('\t'); } if (columnTitles[col] != null) { writer.print(columnTitles[col]); } } writer.println(); } for (int row = 0; row < rowCount; row++) { for (int col = 0; col < getColumnCount(); col++) { if (col != 0) { writer.print('\t'); } String entry = getString(row, col); // just write null entries as blanks, rather than spewing 'null' // all over the spreadsheet file. if (entry != null) { writer.print(entry); } } writer.println(); } writer.flush(); }
protected void writeTSV(PrintWriter writer) { if (columnTitles != null) { for (int col = 0; col < columns.length; col++) { if (col != 0) { writer.print('\t'); } if (columnTitles[col] != null) { writer.print(columnTitles[col]); } } writer.println(); } for (int row = 0; row < rowCount; row++) { for (int col = 0; col < getColumnCount(); col++) { if (col != 0) { writer.print('\t'); } String entry = getString(row, col); // just write null entries as blanks, rather than spewing 'null' // all over the spreadsheet file. if (entry != null) { writer.print(entry); } } writer.println(); } writer.flush(); }
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(); }
/** * 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; }
/** * Same as getColumnIndex(), but creates the column if it doesn't exist. * Named this way to not conflict with checkColumn(), an internal function * used to ensure that a columns exists, and also to denote that it returns * an int for the column index. * @param title column title * @return index of a new or previously existing column */ public int checkColumnIndex(String title) { int index = getColumnIndex(title, false); if (index != -1) { return index; } addColumn(title); return getColumnCount() - 1; }
/** * Same as getColumnIndex(), but creates the column if it doesn't exist. * Named this way to not conflict with checkColumn(), an internal function * used to ensure that a columns exists, and also to denote that it returns * an int for the column index. * @param title column title * @return index of a new or previously existing column */ public int checkColumnIndex(String title) { int index = getColumnIndex(title, false); if (index != -1) { return index; } addColumn(title); return getColumnCount() - 1; }
/** * 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; }
protected void writeCSV(PrintWriter writer) { if (columnTitles != null) { for (int col = 0; col < columns.length; col++) { if (col != 0) { writer.print(','); } if (columnTitles[col] != null) { writeEntryCSV(writer, columnTitles[col]); } } writer.println(); } for (int row = 0; row < rowCount; row++) { for (int col = 0; col < getColumnCount(); col++) { if (col != 0) { writer.print(','); } String entry = getString(row, col); // just write null entries as blanks, rather than spewing 'null' // all over the spreadsheet file. if (entry != null) { writeEntryCSV(writer, entry); } } // Prints the newline for the row, even if it's missing writer.println(); } writer.flush(); }
protected void writeCSV(PrintWriter writer) { if (columnTitles != null) { for (int col = 0; col < getColumnCount(); col++) { if (col != 0) { writer.print(','); for (int col = 0; col < getColumnCount(); col++) { if (col != 0) { writer.print(',');
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]); } } } }
for (int col = 0; col < getColumnCount(); col++) { trim(col); int lastColumn = getColumnCount() - 1; while (getColumnCount() > 0 && isEmptyArray(getStringColumn(0))) { removeColumn(0);