public class EasyCSVMap extends Object
| Constructor and Description |
|---|
EasyCSVMap()
Creates EasyCSVMap object.
|
EasyCSVMap(CSVContext csvContext)
Creates EasyCSVMap object.
|
EasyCSVMap(int headerRowIndex)
Creates EasyCSVMap object.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getNumberOfCSVColumns()
Retrieves the total number of columns of the parsed CSV structure
|
int |
getNumberOfCSVRows()
Retrieves the total number of rows of the parsed CSV structure (including data rows and header rows)
|
Iterator<Map<String,String>> |
getRowIterator()
An iterator over the rows of the CSV file, including a potentially existing header line.
|
Map<Integer,String> |
getValues(String csvSelectorString)
Convenient method to retrieve the value of particular cells from the CSV structure.
|
List<Map<String,String>> |
parseCsv(String csvString)
Parses the given CSV format
|
List<Map<String,String>> |
parseCsvFromFile(String csvFilePath)
Parses the given CSV file
|
void |
saveToFile(String pathToCsv)
Writes the CSV structure to file
|
void |
setValues(String csvSelectorString,
String value)
Convenient method to set the values of particular cells in the CSV structure.
|
public EasyCSVMap(int headerRowIndex)
headerRowIndex - An arbitrary row in the CSV can be used as header row.public EasyCSVMap()
EasyCSVMap(int) to construct the EasyCSVMap object.public EasyCSVMap(CSVContext csvContext)
public List<Map<String,String>> parseCsvFromFile(String csvFilePath)
csvFilePath - path to CSV filepublic List<Map<String,String>> parseCsv(String csvString)
csvString - CSV format as String@Nonnull public Map<Integer,String> getValues(String csvSelectorString)
Beside simply using numeric row specifications it is also possible to use more complex ones, e.g. search a row via comparing column values with regular expressions. Example:
When using regular expressions as row specification it is possible that it matches more than just one row. hence, the method may return more then just one value.
csvPath - public void setValues(String csvSelectorString, String value)
EasyCSVMap#getValue(String). The given value is set for all cells matching the given selector expressions.
If a header row was specified the corresponding row is read-only. An exception is thrown when trying the change a value of the header row.csvPath - public Iterator<Map<String,String>> getRowIterator()
public void saveToFile(String pathToCsv)
pathToCsv - public int getNumberOfCSVRows()
public int getNumberOfCSVColumns()
Copyright © 2016. All Rights Reserved.