public class CsvHelper extends Object
| Constructor and Description |
|---|
CsvHelper() |
| Modifier and Type | Method and Description |
|---|---|
void |
AddRow(CsvObject csv)
adds row to csv file file path: csv.path + csv.csvFile using csvObject eg.
|
void |
appendCsv(CsvObject csv) |
List<String[]> |
getAllCsvData(String filePath)
gets all csv data in list of string arrays
|
List<String[]> |
getAllCsvData(String filePath,
CsvObject csv)
gets all csv data in list of string arrays
|
List<String[]> |
getAllCsvData(String filePath,
int startingRow,
boolean skipEmptyRows)
gets all csv data in list of string arrays
|
List<String[]> |
getAllCsvDataFirstRowAsHeader(String filePath)
gets all csv data files skipping first row as header
|
String |
getCellData(CsvObject csv)
gets single cell data in csv file
|
int |
getColumnIndex(String column,
String filePath)
get column index by column value
|
int |
getRowIndex(String id,
String filePath)
get row index in csv file that equal id value
|
void |
writeNewCsv(CsvObject csv)
file path: csv.path + csv.csvFile using csvObject
|
void |
writeToCell(CsvObject csv,
String value)
update cell based on row and column.
|
void |
writeToCell(CsvObject csv,
String value,
String csvPath)
update cell based on row and column.
|
public String getCellData(CsvObject csv) throws Exception
csv - - requires. csv.row, csv.column, csv.csvFileExceptionpublic List<String[]> getAllCsvData(String filePath, CsvObject csv)
csv - - requires. csv.csvFileExceptionpublic List<String[]> getAllCsvData(String filePath)
csv - - requires. csv.csvFileExceptionpublic List<String[]> getAllCsvData(String filePath, int startingRow, boolean skipEmptyRows)
csv - - requires. csv.csvFileExceptionpublic List<String[]> getAllCsvDataFirstRowAsHeader(String filePath)
filePath - public void writeNewCsv(CsvObject csv)
csv - - required: csv.csvFile, csv.value value: String [] record =
"3,David,Feezor,USA,40".split(",");Exceptionpublic void AddRow(CsvObject csv)
csv - Exceptionpublic void writeToCell(CsvObject csv, String value)
csv - csv file to updatevalue - value to writepublic void writeToCell(CsvObject csv, String value, String csvPath)
csv - csv file to updatevalue - value to writecsvPath - path to the csv data relative to root directorypublic void appendCsv(CsvObject csv)
csv - - required: csv.csvFile, csv.value value: String [] record =
"3,David,Feezor,USA,40".split(",");Exceptionpublic int getRowIndex(String id, String filePath)
id - filePath - Copyright © 2022. All rights reserved.