Package org.anchoranalysis.io.input.csv
Class ReadByLine
Object
ReadByLine
- All Implemented Interfaces:
AutoCloseable
An opened-CSV file that is read line-by-line and processed.
- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsConstructorDescriptionReadByLine
(Path filePath, CSVReader csvReader) Creates a newReadByLine
instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes any opened-filesString[]
headers()
The headers of the CSV file.int
read
(ProcessCSVLine lineProcessor) Reads a CSV-file iterating through each row and passing it to lineProcessor
-
Constructor Details
-
ReadByLine
Creates a newReadByLine
instance.- Parameters:
filePath
- Path to the CSV file that will be read.csvReader
- How the CSV will be read.
-
-
Method Details
-
headers
The headers of the CSV file.- Returns:
- a string or null if the headers don't exist.
- Throws:
CSVReaderException
- if the file cannot be opened successfully.
-
read
Reads a CSV-file iterating through each row and passing it to lineProcessorThis will automatically close any opened-files
- Parameters:
lineProcessor
- called one for each row incrementally- Returns:
- the number of lines read
- Throws:
CSVReaderException
- if any file-system I/O errors occur.
-
close
Closes any opened-files- Specified by:
close
in interfaceAutoCloseable
- Throws:
CSVReaderException
- if any file-system I/O errors occur.
-