Package org.ejml.ops
Class ReadCsv
java.lang.Object
org.ejml.ops.ReadCsv
- Direct Known Subclasses:
ReadMatrixCsv
public class ReadCsv extends Object
Base class for reading CSV formatted files. CSV stands for column-space-value where text strings are separated by a space character. The values are typically stored in a human readable format. The encoded text for a single variable is referred to as a word.
Comments are allowed and identified by starting a line with the comment character. The comment character is user configurable. By default there is no comment character.
-
Constructor Summary
Constructors Constructor Description ReadCsv(InputStream in)Constructor for ReadCsv -
Method Summary
Modifier and Type Method Description protected @Nullable List<String>extractWords()Finds the next valid line of words in the stream and extracts them.intgetLineNumber()Returns how many lines have been read.BufferedReadergetReader()Returns the reader that it is using internally.protected List<String>parseWords(String line)Extracts the words from a string.voidsetComment(char comment)Sets the comment character.
-
Constructor Details
-
ReadCsv
Constructor for ReadCsv- Parameters:
in- Where the input comes from.
-
-
Method Details
-
setComment
public void setComment(char comment)Sets the comment character. All lines that start with this character will be ignored.- Parameters:
comment- The new comment character.
-
getLineNumber
public int getLineNumber()Returns how many lines have been read.- Returns:
- Line number
-
getReader
Returns the reader that it is using internally.- Returns:
- The reader.
-
extractWords
Finds the next valid line of words in the stream and extracts them.- Returns:
- List of valid words on the line. null if the end of the file has been reached.
- Throws:
IOException
-
parseWords
Extracts the words from a string. Words are seperated by a space character.- Parameters:
line- The line that is being parsed.- Returns:
- A list of words contained on the line.
-