processing.data
Class Table
- java.lang.Object
-
- processing.data.Table
-
public class Table extends java.lang.ObjectGeneric class for handling tabular data, typically from a CSV, TSV, or other sort of spreadsheet file.
CSV files are comma separated values, often with the data in quotes. TSV files use tabs as separators, and usually don't bother with the quotes.
File names should end with .csv if they're comma separated.
A rough "spec" for CSV can be found here.
-
-
Field Summary
Fields Modifier and Type Field and Description static intCATEGORYstatic intDOUBLEstatic intFLOATstatic intINTstatic intLONGstatic intSTRING
-
Constructor Summary
Constructors Constructor and Description Table()Creates a new, empty table.Table(java.io.File file)Table(java.io.File file, java.lang.String options)version that uses a File object; future releases (or data types) may include additional optimizations hereTable(java.io.InputStream input)Table(java.io.InputStream input, java.lang.String options)Read the table from a stream.Table(java.lang.Iterable<TableRow> rows)Table(java.sql.ResultSet rs)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description voidaddColumn()voidaddColumn(java.lang.String title)voidaddColumn(java.lang.String title, int type)TableRowaddRow()TableRowaddRow(java.lang.Object[] columnData)TableRowaddRow(TableRow source)voidaddRows(Table source)intcheckColumnIndex(java.lang.String title)Same as getColumnIndex(), but creates the column if it doesn't exist.voidclearRows()Tablecopy()Make a copy of the current tablestatic java.lang.StringextensionOptions(boolean loading, java.lang.String filename, java.lang.String options)TableRowfindRow(java.lang.String value, int column)TableRowfindRow(java.lang.String value, java.lang.String columnName)intfindRowIndex(java.lang.String value, int column)Return the row that contains the first String that matches.intfindRowIndex(java.lang.String value, java.lang.String columnName)Return the row that contains the first String that matches.int[]findRowIndices(java.lang.String value, int column)Return a list of rows that contain the String passed in.int[]findRowIndices(java.lang.String value, java.lang.String columnName)Return a list of rows that contain the String passed in.java.util.Iterator<TableRow>findRowIterator(java.lang.String value, int column)java.util.Iterator<TableRow>findRowIterator(java.lang.String value, java.lang.String columnName)java.lang.Iterable<TableRow>findRows(java.lang.String value, int column)java.lang.Iterable<TableRow>findRows(java.lang.String value, java.lang.String columnName)intgetColumnCount()intgetColumnIndex(java.lang.String columnName)java.lang.StringgetColumnTitle(int col)java.lang.String[]getColumnTitles()intgetColumnType(int column)Returns one of Table.STRING, Table.INT, etc...intgetColumnType(java.lang.String columnName)int[]getColumnTypes()doublegetDouble(int row, int column)doublegetDouble(int row, java.lang.String columnName)double[]getDoubleColumn(int col)double[]getDoubleColumn(java.lang.String name)double[]getDoubleRow(int row)floatgetFloat(int row, int column)Get a float value from the specified row and column.floatgetFloat(int row, java.lang.String columnName)float[]getFloatColumn(int col)float[]getFloatColumn(java.lang.String name)FloatDictgetFloatDict(int keyColumn, int valueColumn)FloatDictgetFloatDict(java.lang.String keyColumnName, java.lang.String valueColumnName)FloatListgetFloatList(int column)FloatListgetFloatList(java.lang.String columnName)float[]getFloatRow(int row)intgetInt(int row, int column)intgetInt(int row, java.lang.String columnName)int[]getIntColumn(int col)int[]getIntColumn(java.lang.String name)IntDictgetIntDict(int keyColumn, int valueColumn)IntDictgetIntDict(java.lang.String keyColumnName, java.lang.String valueColumnName)IntListgetIntList(int column)IntListgetIntList(java.lang.String columnName)int[]getIntRow(int row)longgetLong(int row, int column)longgetLong(int row, java.lang.String columnName)long[]getLongColumn(int col)long[]getLongColumn(java.lang.String name)long[]getLongRow(int row)IntDictgetOrder(int column)IntDictgetOrder(java.lang.String columnName)TableRowgetRow(int row)intgetRowCount()java.lang.StringgetString(int row, int column)Get a String value from the table.java.lang.StringgetString(int row, java.lang.String columnName)java.lang.String[]getStringColumn(int column)java.lang.String[]getStringColumn(java.lang.String columnName)StringDictgetStringDict(int keyColumn, int valueColumn)StringDictgetStringDict(java.lang.String keyColumnName, java.lang.String valueColumnName)StringListgetStringList(int column)StringListgetStringList(java.lang.String columnName)java.lang.String[]getStringRow(int row)IntDictgetTally(int column)IntDictgetTally(java.lang.String columnName)java.lang.String[]getUnique(int column)java.lang.String[]getUnique(java.lang.String columnName)booleanhasColumnTitles()voidinsertColumn(int index)voidinsertColumn(int index, java.lang.String title)voidinsertColumn(int index, java.lang.String title, int type)voidinsertRow(int insert, java.lang.Object[] columnData)intlastRowIndex()TableRowmatchRow(java.lang.String regexp, int column)TableRowmatchRow(java.lang.String regexp, java.lang.String columnName)intmatchRowIndex(java.lang.String regexp, int column)Return the row that contains the first String that matches.intmatchRowIndex(java.lang.String what, java.lang.String columnName)Return the row that contains the first String that matches.int[]matchRowIndices(java.lang.String regexp, int column)Return a list of rows that contain the String passed in.int[]matchRowIndices(java.lang.String what, java.lang.String columnName)Return a list of rows that match the regex passed in.java.util.Iterator<TableRow>matchRowIterator(java.lang.String value, int column)java.util.Iterator<TableRow>matchRowIterator(java.lang.String value, java.lang.String columnName)java.lang.Iterable<TableRow>matchRows(java.lang.String regexp, int column)java.lang.Iterable<TableRow>matchRows(java.lang.String regexp, java.lang.String columnName)voidparseInto(java.lang.Object enclosingObject, java.lang.String fieldName)incomplete, do not usevoidprint()voidremoveColumn(int column)voidremoveColumn(java.lang.String columnName)voidremoveRow(int row)java.lang.String[]removeTitleRow()Deprecated.voidremoveTokens(java.lang.String tokens)Remove any of the specified characters from the entire table.voidremoveTokens(java.lang.String tokens, int column)Removed any of the specified characters from a column.voidremoveTokens(java.lang.String tokens, java.lang.String columnName)voidreplace(java.lang.String orig, java.lang.String replacement)Replace a String with another.voidreplace(java.lang.String orig, java.lang.String replacement, int col)voidreplace(java.lang.String orig, java.lang.String replacement, java.lang.String colName)voidreplaceAll(java.lang.String regex, java.lang.String replacement)voidreplaceAll(java.lang.String regex, java.lang.String replacement, int column)voidreplaceAll(java.lang.String regex, java.lang.String replacement, java.lang.String columnName)Run String.replaceAll() on all entries in a column.java.lang.Iterable<TableRow>rows()Note that this one iterator instance is shared by any calls to iterate the rows of this table.java.lang.Iterable<TableRow>rows(int[] indices)booleansave(java.io.File file, java.lang.String options)booleansave(java.io.OutputStream output, java.lang.String options)voidsetColumnCount(int newCount)Change the number of columns in this table.voidsetColumnTitle(int column, java.lang.String title)voidsetColumnTitles(java.lang.String[] titles)voidsetColumnType(int column, int newType)Sets the column type.voidsetColumnType(int column, java.lang.String columnType)Set the data type for a column so that using it is more efficient.voidsetColumnType(java.lang.String columnName, int newType)voidsetColumnType(java.lang.String columnName, java.lang.String columnType)voidsetColumnTypes(int[] types)voidsetColumnTypes(Table dictionary)Set the titles (and if a second column is present) the data types for this table based on a file loaded separately.voidsetDouble(int row, int column, double value)voidsetDouble(int row, java.lang.String columnName, double value)voidsetFloat(int row, int column, float value)voidsetFloat(int row, java.lang.String columnName, float value)voidsetInt(int row, int column, int value)voidsetInt(int row, java.lang.String columnName, int value)voidsetLong(int row, int column, long value)voidsetLong(int row, java.lang.String columnName, long value)voidsetMissingDouble(double value)voidsetMissingFloat(float value)voidsetMissingInt(int value)voidsetMissingLong(long value)voidsetMissingString(java.lang.String value)Treat entries with this string as "missing".voidsetRow(int row, java.lang.Object[] pieces)TableRowsetRow(int row, TableRow source)voidsetRowCount(int newCount)voidsetString(int row, int column, java.lang.String value)voidsetString(int row, java.lang.String columnName, java.lang.String value)voidsetTableType(java.lang.String type)Set the entire table to a specific data type.voidsort(int column)voidsort(java.lang.String columnName)voidsortReverse(int column)voidsortReverse(java.lang.String columnName)voidtrim()voidtrim(int column)voidtrim(java.lang.String columnName)TabletypedParse(java.io.InputStream input, java.lang.String options)voidwrite(java.io.PrintWriter writer)
-
-
-
Field Detail
-
STRING
public static final int STRING
- See Also:
- Constant Field Values
-
INT
public static final int INT
- See Also:
- Constant Field Values
-
LONG
public static final int LONG
- See Also:
- Constant Field Values
-
FLOAT
public static final int FLOAT
- See Also:
- Constant Field Values
-
DOUBLE
public static final int DOUBLE
- See Also:
- Constant Field Values
-
CATEGORY
public static final int CATEGORY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Table
public Table()
Creates a new, empty table. Use addRow() to add additional rows.
-
Table
public Table(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
Table
public Table(java.io.File file, java.lang.String options) throws java.io.IOExceptionversion that uses a File object; future releases (or data types) may include additional optimizations here- Throws:
java.io.IOException
-
Table
public Table(java.io.InputStream input) throws java.io.IOException- Throws:
java.io.IOException
-
Table
public Table(java.io.InputStream input, java.lang.String options) throws java.io.IOExceptionRead the table from a stream. Possible options include:- csv - parse the table as comma-separated values
- tsv - parse the table as tab-separated values
- newlines - this CSV file contains newlines inside individual cells
- header - this table has a header (title) row
- Parameters:
input-options-- Throws:
java.io.IOException
-
Table
public Table(java.lang.Iterable<TableRow> rows)
-
Table
public Table(java.sql.ResultSet rs)
-
-
Method Detail
-
typedParse
public Table typedParse(java.io.InputStream input, java.lang.String options) throws java.io.IOException
- Throws:
java.io.IOException
-
extensionOptions
public static java.lang.String extensionOptions(boolean loading, java.lang.String filename, java.lang.String options)
-
parseInto
public void parseInto(java.lang.Object enclosingObject, java.lang.String fieldName)incomplete, do not use
-
save
public boolean save(java.io.File file, java.lang.String options) throws java.io.IOException- Throws:
java.io.IOException
-
save
public boolean save(java.io.OutputStream output, java.lang.String options)
-
addColumn
public void addColumn()
- See Also:
removeColumn(String)
-
addColumn
public void addColumn(java.lang.String title)
- Parameters:
title- the title to be used for the new column
-
addColumn
public void addColumn(java.lang.String title, int type)- Parameters:
type- the type to be used for the new column: INT, LONG, FLOAT, DOUBLE, STRING, or CATEGORY
-
insertColumn
public void insertColumn(int index)
-
insertColumn
public void insertColumn(int index, java.lang.String title)
-
insertColumn
public void insertColumn(int index, java.lang.String title, int type)
-
removeColumn
public void removeColumn(java.lang.String columnName)
- Parameters:
columnName- the title of the column to be removed- See Also:
addColumn()
-
removeColumn
public void removeColumn(int column)
- Parameters:
column- the index number of the column to be removed
-
getColumnCount
public int getColumnCount()
- See Also:
getRowCount()
-
setColumnCount
public void setColumnCount(int newCount)
Change the number of columns in this table. Resizes all rows to ensure the same number of columns in each row. Entries in the additional (empty) columns will be set to null.- Parameters:
newCount-
-
setColumnType
public void setColumnType(java.lang.String columnName, java.lang.String columnType)
-
setColumnType
public void setColumnType(int column, java.lang.String columnType)Set the data type for a column so that using it is more efficient.- Parameters:
column- the column to changecolumnType- One of int, long, float, double, string, or category.
-
setColumnType
public void setColumnType(java.lang.String columnName, int newType)
-
setColumnType
public void setColumnType(int column, int newType)Sets the column type. If data already exists, then it'll be converted to the new type.- Parameters:
column- the column whose type should be changednewType- something fresh, maybe try an int or a float for size?
-
setTableType
public void setTableType(java.lang.String type)
Set the entire table to a specific data type.
-
setColumnTypes
public void setColumnTypes(int[] types)
-
setColumnTypes
public void setColumnTypes(Table dictionary)
Set the titles (and if a second column is present) the data types for this table based on a file loaded separately. This will look for the title in column 0, and the type in column 1. Better yet, specify a column named "title" and another named "type" in the dictionary table to future-proof the code.- Parameters:
dictionary-
-
getColumnType
public int getColumnType(java.lang.String columnName)
-
getColumnType
public int getColumnType(int column)
Returns one of Table.STRING, Table.INT, etc...
-
getColumnTypes
public int[] getColumnTypes()
-
removeTitleRow
@Deprecated public java.lang.String[] removeTitleRow()
Deprecated.Remove the first row from the data set, and use it as the column titles. Use loadTable("table.csv", "header") instead.
-
setColumnTitles
public void setColumnTitles(java.lang.String[] titles)
-
setColumnTitle
public void setColumnTitle(int column, java.lang.String title)
-
hasColumnTitles
public boolean hasColumnTitles()
-
getColumnTitles
public java.lang.String[] getColumnTitles()
-
getColumnTitle
public java.lang.String getColumnTitle(int col)
-
getColumnIndex
public int getColumnIndex(java.lang.String columnName)
-
checkColumnIndex
public int checkColumnIndex(java.lang.String title)
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.- Parameters:
title- column title- Returns:
- index of a new or previously existing column
-
getRowCount
public int getRowCount()
- See Also:
getColumnCount()
-
lastRowIndex
public int lastRowIndex()
-
clearRows
public void clearRows()
- See Also:
addRow(),removeRow(int)
-
setRowCount
public void setRowCount(int newCount)
-
addRow
public TableRow addRow()
- See Also:
removeRow(int),clearRows()
-
addRow
public TableRow addRow(TableRow source)
- Parameters:
source- a reference to the original row to be duplicated
-
addRow
public TableRow addRow(java.lang.Object[] columnData)
-
addRows
public void addRows(Table source)
-
insertRow
public void insertRow(int insert, java.lang.Object[] columnData)
-
removeRow
public void removeRow(int row)
- Parameters:
row- ID number of the row to remove- See Also:
addRow(),clearRows()
-
setRow
public void setRow(int row, java.lang.Object[] pieces)
-
getRow
public TableRow getRow(int row)
- Parameters:
row- ID number of the row to get- See Also:
rows(),findRow(String, int),findRows(String, int),matchRow(String, int),matchRows(String, int)
-
rows
public java.lang.Iterable<TableRow> rows()
Note that this one iterator instance is shared by any calls to iterate the rows of this table. This is very efficient, but not thread-safe. If you want to iterate in a multi-threaded manner, don't use the iterator.
-
rows
public java.lang.Iterable<TableRow> rows(int[] indices)
-
getInt
public int getInt(int row, int column)- Parameters:
row- ID number of the row to referencecolumn- ID number of the column to reference- See Also:
getFloat(int, int),getString(int, int),getStringColumn(String),setInt(int, int, int),setFloat(int, int, float),setString(int, int, String)
-
getInt
public int getInt(int row, java.lang.String columnName)- Parameters:
columnName- title of the column to reference
-
setMissingInt
public void setMissingInt(int value)
-
setInt
public void setInt(int row, int column, int value)- Parameters:
row- ID number of the target rowcolumn- ID number of the target columnvalue- value to assign- See Also:
setFloat(int, int, float),setString(int, int, String),getInt(int, int),getFloat(int, int),getString(int, int),getStringColumn(String)
-
setInt
public void setInt(int row, java.lang.String columnName, int value)- Parameters:
columnName- title of the target column
-
getIntColumn
public int[] getIntColumn(java.lang.String name)
-
getIntColumn
public int[] getIntColumn(int col)
-
getIntRow
public int[] getIntRow(int row)
-
getLong
public long getLong(int row, int column)
-
getLong
public long getLong(int row, java.lang.String columnName)
-
setMissingLong
public void setMissingLong(long value)
-
setLong
public void setLong(int row, int column, long value)
-
setLong
public void setLong(int row, java.lang.String columnName, long value)
-
getLongColumn
public long[] getLongColumn(java.lang.String name)
-
getLongColumn
public long[] getLongColumn(int col)
-
getLongRow
public long[] getLongRow(int row)
-
getFloat
public float getFloat(int row, int column)Get a float value from the specified row and column. If the value is null or not parseable as a float, the "missing" value is returned. By default, this is Float.NaN, but can be controlled with setMissingFloat().- Parameters:
row- ID number of the row to referencecolumn- ID number of the column to reference- See Also:
getInt(int, int),getString(int, int),getStringColumn(String),setInt(int, int, int),setFloat(int, int, float),setString(int, int, String)
-
getFloat
public float getFloat(int row, java.lang.String columnName)- Parameters:
columnName- title of the column to reference
-
setMissingFloat
public void setMissingFloat(float value)
-
setFloat
public void setFloat(int row, int column, float value)- Parameters:
row- ID number of the target rowcolumn- ID number of the target columnvalue- value to assign- See Also:
setInt(int, int, int),setString(int, int, String),getInt(int, int),getFloat(int, int),getString(int, int),getStringColumn(String)
-
setFloat
public void setFloat(int row, java.lang.String columnName, float value)- Parameters:
columnName- title of the target column
-
getFloatColumn
public float[] getFloatColumn(java.lang.String name)
-
getFloatColumn
public float[] getFloatColumn(int col)
-
getFloatRow
public float[] getFloatRow(int row)
-
getDouble
public double getDouble(int row, int column)
-
getDouble
public double getDouble(int row, java.lang.String columnName)
-
setMissingDouble
public void setMissingDouble(double value)
-
setDouble
public void setDouble(int row, int column, double value)
-
setDouble
public void setDouble(int row, java.lang.String columnName, double value)
-
getDoubleColumn
public double[] getDoubleColumn(java.lang.String name)
-
getDoubleColumn
public double[] getDoubleColumn(int col)
-
getDoubleRow
public double[] getDoubleRow(int row)
-
getString
public java.lang.String getString(int row, int column)Get a String value from the table. If the row is longer than the table- Parameters:
row- ID number of the row to referencecolumn- ID number of the column to reference- See Also:
getInt(int, int),getFloat(int, int),getStringColumn(String),setInt(int, int, int),setFloat(int, int, float),setString(int, int, String)
-
getString
public java.lang.String getString(int row, java.lang.String columnName)- Parameters:
columnName- title of the column to reference
-
setMissingString
public void setMissingString(java.lang.String value)
Treat entries with this string as "missing". Also used for categorial.
-
setString
public void setString(int row, int column, java.lang.String value)- Parameters:
row- ID number of the target rowcolumn- ID number of the target columnvalue- value to assign- See Also:
setInt(int, int, int),setFloat(int, int, float),getInt(int, int),getFloat(int, int),getString(int, int),getStringColumn(String)
-
setString
public void setString(int row, java.lang.String columnName, java.lang.String value)- Parameters:
columnName- title of the target column
-
getStringColumn
public java.lang.String[] getStringColumn(java.lang.String columnName)
- Parameters:
columnName- title of the column to search- See Also:
getInt(int, int),getFloat(int, int),getString(int, int),setInt(int, int, int),setFloat(int, int, float),setString(int, int, String)
-
getStringColumn
public java.lang.String[] getStringColumn(int column)
- Parameters:
column- ID number of the column to search
-
getStringRow
public java.lang.String[] getStringRow(int row)
-
findRowIndex
public int findRowIndex(java.lang.String value, int column)Return the row that contains the first String that matches.- Parameters:
value- the String to matchcolumn- ID number of the column to search
-
findRowIndex
public int findRowIndex(java.lang.String value, java.lang.String columnName)Return the row that contains the first String that matches.- Parameters:
value- the String to matchcolumnName- title of the column to search
-
findRowIndices
public int[] findRowIndices(java.lang.String value, int column)Return a list of rows that contain the String passed in. If there are no matches, a zero length array will be returned (not a null array).- Parameters:
value- the String to matchcolumn- ID number of the column to search
-
findRowIndices
public int[] findRowIndices(java.lang.String value, java.lang.String columnName)Return a list of rows that contain the String passed in. If there are no matches, a zero length array will be returned (not a null array).- Parameters:
value- the String to matchcolumnName- title of the column to search
-
findRow
public TableRow findRow(java.lang.String value, int column)
- Parameters:
value- the value to matchcolumn- ID number of the column to search- See Also:
getRow(int),rows(),findRows(String, int),matchRow(String, int),matchRows(String, int)
-
findRow
public TableRow findRow(java.lang.String value, java.lang.String columnName)
- Parameters:
columnName- title of the column to search
-
findRows
public java.lang.Iterable<TableRow> findRows(java.lang.String value, int column)
- Parameters:
value- the value to matchcolumn- ID number of the column to search- See Also:
getRow(int),rows(),findRow(String, int),matchRow(String, int),matchRows(String, int)
-
findRows
public java.lang.Iterable<TableRow> findRows(java.lang.String value, java.lang.String columnName)
- Parameters:
columnName- title of the column to search
-
findRowIterator
public java.util.Iterator<TableRow> findRowIterator(java.lang.String value, int column)
- Parameters:
value- the value to matchcolumn- ID number of the column to search
-
findRowIterator
public java.util.Iterator<TableRow> findRowIterator(java.lang.String value, java.lang.String columnName)
- Parameters:
columnName- title of the column to search
-
matchRowIndex
public int matchRowIndex(java.lang.String regexp, int column)Return the row that contains the first String that matches.- Parameters:
regexp- the String to matchcolumn- ID number of the column to search
-
matchRowIndex
public int matchRowIndex(java.lang.String what, java.lang.String columnName)Return the row that contains the first String that matches.- Parameters:
what- the String to matchcolumnName- title of the column to search
-
matchRowIndices
public int[] matchRowIndices(java.lang.String regexp, int column)Return a list of rows that contain the String passed in. If there are no matches, a zero length array will be returned (not a null array).- Parameters:
regexp- the String to matchcolumn- ID number of the column to search
-
matchRowIndices
public int[] matchRowIndices(java.lang.String what, java.lang.String columnName)Return a list of rows that match the regex passed in. If there are no matches, a zero length array will be returned (not a null array).- Parameters:
what- the String to matchcolumnName- title of the column to search
-
matchRow
public TableRow matchRow(java.lang.String regexp, int column)
- Parameters:
regexp- the regular expression to matchcolumn- ID number of the column to search- See Also:
getRow(int),rows(),findRow(String, int),findRows(String, int),matchRows(String, int)
-
matchRow
public TableRow matchRow(java.lang.String regexp, java.lang.String columnName)
- Parameters:
columnName- title of the column to search
-
matchRows
public java.lang.Iterable<TableRow> matchRows(java.lang.String regexp, int column)
- Parameters:
regexp- the regular expression to matchcolumn- ID number of the column to search- See Also:
getRow(int),rows(),findRow(String, int),findRows(String, int),matchRow(String, int)
-
matchRows
public java.lang.Iterable<TableRow> matchRows(java.lang.String regexp, java.lang.String columnName)
- Parameters:
columnName- title of the column to search
-
matchRowIterator
public java.util.Iterator<TableRow> matchRowIterator(java.lang.String value, int column)
- Parameters:
value- the regular expression to matchcolumn- ID number of the column to search
-
matchRowIterator
public java.util.Iterator<TableRow> matchRowIterator(java.lang.String value, java.lang.String columnName)
- Parameters:
columnName- title of the column to search
-
replace
public void replace(java.lang.String orig, java.lang.String replacement)Replace a String with another. Set empty entries null by using replace("", null) or use replace(null, "") to go the other direction. If this is a typed table, only String columns will be modified.- Parameters:
orig-replacement-
-
replace
public void replace(java.lang.String orig, java.lang.String replacement, int col)
-
replace
public void replace(java.lang.String orig, java.lang.String replacement, java.lang.String colName)
-
replaceAll
public void replaceAll(java.lang.String regex, java.lang.String replacement)
-
replaceAll
public void replaceAll(java.lang.String regex, java.lang.String replacement, int column)
-
replaceAll
public void replaceAll(java.lang.String regex, java.lang.String replacement, java.lang.String columnName)Run String.replaceAll() on all entries in a column. Only works with columns that are already String values.- Parameters:
regex- the String to matchcolumnName- title of the column to search
-
removeTokens
public void removeTokens(java.lang.String tokens)
Remove any of the specified characters from the entire table.- Parameters:
tokens- a list of individual characters to be removed- See Also:
trim()
-
removeTokens
public void removeTokens(java.lang.String tokens, int column)Removed any of the specified characters from a column. For instance, the following code removes dollar signs and commas from column 2:table.removeTokens(",$", 2);- Parameters:
column- ID number of the column to process
-
removeTokens
public void removeTokens(java.lang.String tokens, java.lang.String columnName)- Parameters:
columnName- title of the column to process
-
trim
public void trim()
- See Also:
removeTokens(String)
-
trim
public void trim(int column)
- Parameters:
column- ID number of the column to trim
-
trim
public void trim(java.lang.String columnName)
- Parameters:
columnName- title of the column to trim
-
sort
public void sort(java.lang.String columnName)
-
sort
public void sort(int column)
-
sortReverse
public void sortReverse(java.lang.String columnName)
-
sortReverse
public void sortReverse(int column)
-
getUnique
public java.lang.String[] getUnique(java.lang.String columnName)
-
getUnique
public java.lang.String[] getUnique(int column)
-
getTally
public IntDict getTally(java.lang.String columnName)
-
getTally
public IntDict getTally(int column)
-
getOrder
public IntDict getOrder(java.lang.String columnName)
-
getOrder
public IntDict getOrder(int column)
-
getIntList
public IntList getIntList(java.lang.String columnName)
-
getIntList
public IntList getIntList(int column)
-
getFloatList
public FloatList getFloatList(java.lang.String columnName)
-
getFloatList
public FloatList getFloatList(int column)
-
getStringList
public StringList getStringList(java.lang.String columnName)
-
getStringList
public StringList getStringList(int column)
-
getIntDict
public IntDict getIntDict(java.lang.String keyColumnName, java.lang.String valueColumnName)
-
getIntDict
public IntDict getIntDict(int keyColumn, int valueColumn)
-
getFloatDict
public FloatDict getFloatDict(java.lang.String keyColumnName, java.lang.String valueColumnName)
-
getFloatDict
public FloatDict getFloatDict(int keyColumn, int valueColumn)
-
getStringDict
public StringDict getStringDict(java.lang.String keyColumnName, java.lang.String valueColumnName)
-
getStringDict
public StringDict getStringDict(int keyColumn, int valueColumn)
-
copy
public Table copy()
Make a copy of the current table
-
write
public void write(java.io.PrintWriter writer)
-
print
public void print()
-
-
DataMelt 3.0 © DataMelt by jWork.ORG