Class CakeCSVParser
java.lang.Object
de.uni_trier.wi2.procake.utils.io.CakeCSVParser
A CSV Parser, that uses the csv package from the Apache group. It's possible, to read a csv file
and create aggregate objects of the entries. For this, a suitable model has to be defined.
Because the creation of the objects runs in parallel, the order of the objects in the object pool isn't deterministic.
- Author:
- Alexander Schultheis, Maximilian Hoffmann
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateAggregateObjects
(String className, boolean containsHeaders, Integer maximumExamples) Parses the CSV file and creates a list of aggregate objects.createAggregateObjects
(String className, Integer maximumExamples) Parses the CSV file and creates a list of aggregate objects.void
Do not use a mapping file for processing the CSV file.char
void
setDelimiter
(char delimiter) void
setFilename
(String filename) void
setMappingFile
(String filename)
-
Constructor Details
-
CakeCSVParser
public CakeCSVParser()
-
-
Method Details
-
getFilename
-
setFilename
-
createAggregateObjects
Parses the CSV file and creates a list of aggregate objects. Thereby, the source CSV file contains a header row with the attribute names.- Parameters:
className
- the name of the class every example for the CSV belongs tomaximumExamples
- the maximum number to process. Ignore of null- Returns:
- the list of parsed CSV entries
- See Also:
-
createAggregateObjects
public List<AggregateObject> createAggregateObjects(String className, boolean containsHeaders, Integer maximumExamples) Parses the CSV file and creates a list of aggregate objects. It can be set if the CSV file contains a header row with the attribute names. The choice of the parametercontainsHeaders
and the value ofmappingFile
determine the behavior of this method. IfmappingFile
is not set and the file contains no headers, an exception will be thrown. In contrast, if the file contains headers then those will be used to map the values to the correct attributes. IfmappingFile
is set and the file contains no headers, then the parser can only work properly if column numbers are mapped to attribute names. If the file contains header information andmappingFile
is set then the parser will use the given mappings, either column number or column name mappings, during processing.- Parameters:
className
- the name of the class every example for the CSV belongs tocontainsHeaders
- if the CSV file to parse contains headersmaximumExamples
- the maximum number to process. Ignore of null- Returns:
- the list of parsed CSV entries
-
setMappingFile
-
disableMapping
public void disableMapping()Do not use a mapping file for processing the CSV file. The parser will only work in this configuration if the CSV file contains a header row and the column names in the header row are equal to the attribute names in the aggregate object. -
getDelimiter
public char getDelimiter() -
setDelimiter
public void setDelimiter(char delimiter)
-