Class FeatureCSVWriter
Object
org.anchoranalysis.feature.io.csv.FeatureCSVWriter
public class FeatureCSVWriter extends Object
Writes the results of feature-calculations as a CSV file.
- Author:
- Owen Feehan
-
Field Summary
Fields Modifier and Type Field Description static intNUMBER_DECIMAL_PLACESThe number of decimal places to use fordoublevalues, unlessvisuallyShortened==true. -
Constructor Summary
Constructors Constructor Description FeatureCSVWriter(CSVWriter writer, boolean visuallyShortenedDecimals)Creates for aCSVWriter. -
Method Summary
Modifier and Type Method Description voidaddRow(List<TypedValue> values)Directly adds a row in the form of typed-values.voidaddRow(LabelledResultsVector results)Directly adds a row of feature-values.voidclose()Closes any open file-handles.static Optional<FeatureCSVWriter>create(FeatureCSVMetadata metadata, org.anchoranalysis.io.output.outputter.Outputter outputter, boolean visuallyShortenedDecimals)Maybe creates aFeatureCSVWriterdepending if the output is allowed.
-
Field Details
-
NUMBER_DECIMAL_PLACES
public static final int NUMBER_DECIMAL_PLACESThe number of decimal places to use fordoublevalues, unlessvisuallyShortened==true.- See Also:
- Constant Field Values
-
-
Constructor Details
-
FeatureCSVWriter
Creates for aCSVWriter.- Parameters:
writer- underlying CSV writer, which if null, it means the writer is disabled.visuallyShortenedDecimals- when truedoublevalues are printed to be as short as possible without losing precision, otherwse withNUMBER_DECIMAL_PLACES.
-
-
Method Details
-
create
public static Optional<FeatureCSVWriter> create(FeatureCSVMetadata metadata, org.anchoranalysis.io.output.outputter.Outputter outputter, boolean visuallyShortenedDecimals) throws org.anchoranalysis.io.output.error.OutputWriteFailedExceptionMaybe creates aFeatureCSVWriterdepending if the output is allowed.- Parameters:
metadata- metadata needed for writing the feature-results.outputter- determines if the output is allowed.visuallyShortenedDecimals- when truedoublevalues are printed to be as short as possible without losing precision.- Returns:
- a write, if it is allowed.
- Throws:
org.anchoranalysis.io.output.error.OutputWriteFailedException- if the CSV file cannot be created successfully.
-
addRow
Directly adds a row of feature-values.- Parameters:
results- results for the row, along with corresponding labels.
-
addRow
Directly adds a row in the form of typed-values.- Parameters:
values- a list of typed-values corresponding to a row in a CSV file.
-
close
public void close()Closes any open file-handles.This operation should always be called once at the end of writing.
-