Class CsvHelper


  • public class CsvHelper
    extends Object
    • Constructor Detail

      • CsvHelper

        public CsvHelper()
    • 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 update
        value - 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 update
        value - value to write
        csvPath - 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:
      • getColumnIndex

        public int getColumnIndex​(String column,
                                  String filePath)
        get column index by column value
        Parameters:
        column -
        filePath -
        Returns: