Package core.helpers.csvHelper
Class CsvHelper
- java.lang.Object
-
- core.helpers.csvHelper.CsvHelper
-
public class CsvHelper extends Object
-
-
Constructor Summary
Constructors Constructor Description CsvHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidAddRow(CsvObject csv)adds row to csv file file path: csv.path + csv.csvFile using csvObject eg.voidappendCsv(CsvObject csv)List<String[]>getAllCsvData(String filePath)gets all csv data in list of string arraysList<String[]>getAllCsvData(String filePath, int startingRow, boolean skipEmptyRows)gets all csv data in list of string arraysList<String[]>getAllCsvData(String filePath, CsvObject csv)gets all csv data in list of string arraysList<String[]>getAllCsvDataFirstRowAsHeader(String filePath)gets all csv data files skipping first row as headerStringgetCellData(CsvObject csv)gets single cell data in csv fileintgetColumnIndex(String column, String filePath)get column index by column valueintgetRowIndex(String id, String filePath)get row index in csv file that equal id valuevoidwriteNewCsv(CsvObject csv)file path: csv.path + csv.csvFile using csvObjectvoidwriteToCell(CsvObject csv, String value)update cell based on row and column.voidwriteToCell(CsvObject csv, String value, String csvPath)update cell based on row and column.
-
-
-
Method Detail
-
getCellData
public String getCellData(CsvObject csv) throws Exception
gets single cell data in csv file- Parameters:
csv- - requires. csv.row, csv.column, csv.csvFile- Returns:
- Throws:
Exception
-
getAllCsvData
public List<String[]> getAllCsvData(String filePath, CsvObject csv)
gets all csv data in list of string arrays- Parameters:
csv- - requires. csv.csvFile- Returns:
- Throws:
Exception
-
getAllCsvData
public List<String[]> getAllCsvData(String filePath)
gets all csv data in list of string arrays- Parameters:
csv- - requires. csv.csvFile- Returns:
- Throws:
Exception
-
getAllCsvData
public List<String[]> getAllCsvData(String filePath, int startingRow, boolean skipEmptyRows)
gets all csv data in list of string arrays- Parameters:
csv- - requires. csv.csvFile- Returns:
- Throws:
Exception
-
getAllCsvDataFirstRowAsHeader
public List<String[]> getAllCsvDataFirstRowAsHeader(String filePath)
gets all csv data files skipping first row as header- Parameters:
filePath-- Returns:
-
writeNewCsv
public void writeNewCsv(CsvObject csv)
file path: csv.path + csv.csvFile using csvObject- Parameters:
csv- - required: csv.csvFile, csv.value value: String [] record = "3,David,Feezor,USA,40".split(",");- Throws:
Exception
-
AddRow
public void AddRow(CsvObject csv)
adds row to csv file file path: csv.path + csv.csvFile using csvObject eg. csv.value: String [] record = "3,David,Feezor,USA,40".split(",");- Parameters:
csv-- Throws:
Exception
-
writeToCell
public void writeToCell(CsvObject csv, String value)
update cell based on row and column. csv object must containe filename, row and column- Parameters:
csv- csv file to updatevalue- value to write
-
writeToCell
public void writeToCell(CsvObject csv, String value, String csvPath)
update cell based on row and column. csv object must contain filename, row and column- Parameters:
csv- csv file to updatevalue- value to writecsvPath- path to the csv data relative to root directory
-
appendCsv
public void appendCsv(CsvObject csv)
- Parameters:
csv- - required: csv.csvFile, csv.value value: String [] record = "3,David,Feezor,USA,40".split(",");- Throws:
Exception
-
getRowIndex
public int getRowIndex(String id, String filePath)
get row index in csv file that equal id value- Parameters:
id-filePath-- Returns:
-
-