Class CSVFileManager

java.lang.Object
com.shaft.tools.io.CSVFileManager
Direct Known Subclasses:
SHAFT.TestData.CSV

public class CSVFileManager extends Object
  • Constructor Details

    • CSVFileManager

      public CSVFileManager(String csvFilePath)
      Creates a new instance of the test data CSV reader using the target CSV file path
      Parameters:
      csvFilePath - target test data CSV file path
  • Method Details

    • getRows

      public List<String[]> getRows()
      Retrieves all rows from the CSV file as a list of string arrays. Each row is represented as an array of strings.
      Returns:
      a list of string arrays, where each array represents a row in the CSV file.
    • getColumns

      public List<String> getColumns()
      Retrieves the column names from the CSV file.
      Returns:
      a list of column names as strings.
    • getColumnsWithData

      public Map<String,List<String>> getColumnsWithData()
      Maps each column name to its corresponding list of row data.
      Returns:
      a map where keys are column names and values are lists of column data.
    • getLastColumn

      public String getLastColumn()
      Retrieves the name of the last column in the CSV file.
      Returns:
      the name of the last column, or null if an error occurs.
    • getSpecificColumnName

      public String getSpecificColumnName(int ColumnNum)
      Retrieves the name of a specific column based on its index.
      Parameters:
      ColumnNum - the 1-based index of the column.
      Returns:
      the column name at the specified index, or null if an error occurs.
    • getSpecificColumnData

      public List<String> getSpecificColumnData(String ColumnName)
      Retrieves all data for a specific column.
      Parameters:
      ColumnName - the name of the column.
      Returns:
      a list of strings containing the column data, or an empty list if an error occurs.
    • getSpecificColumnData

      public List<String> getSpecificColumnData(int ColumnIndex)
      Retrieves all data for a specific column.
      Parameters:
      ColumnIndex - the 1-based index of the column.
      Returns:
      a list of strings containing the column data, or an empty list if an error occurs.
    • getCellData

      public String getCellData(int RowNum, String ColumnName)
      Retrieves a specific cell's data based on row number and column name.
      Parameters:
      RowNum - the 0-based index of the row.
      ColumnName - the name of the column.
      Returns:
      the data in the specified cell, or null if an error occurs.
    • getCellData

      public String getCellData(int RowNum, int ColumnIndex)
      Retrieves a specific cell's data based on row number and column name.
      Parameters:
      RowNum - the 0-based index of the row.
      ColumnIndex - the 1-based index of the column.
      Returns:
      the data in the specified cell, or null if an error occurs.
    • getFirstColumn

      public String getFirstColumn()
      Retrieves the name of the first column in the CSV file.
      Returns:
      the name of the first column,or null if an error occurs.
    • getMinCellValue

      public double getMinCellValue(String columnName)
      Retrieves the minimum value from a specific column.
      Parameters:
      columnName - the name of the column.
      Returns:
      the minimum value in the column, or Double.NaN if an error occurs.
    • getMinCellValue

      public double getMinCellValue(int columnIndex)
      Retrieves the minimum value from a specific column.
      Parameters:
      columnIndex - the index of the column.
      Returns:
      the minimum value in the column, or Double.NaN if an error occurs.
    • getMaxCellValue

      public double getMaxCellValue(String columnName)
      Retrieves the maximum value from a specific column.
      Parameters:
      columnName - the name of the column.
      Returns:
      the maximum value in the column, or Double.NaN if an error occurs.
    • getMaxCellValue

      public double getMaxCellValue(int columnIndex)
      Retrieves the maximum value from a specific column.
      Parameters:
      columnIndex - the name of the column.
      Returns:
      the maximum value in the column, or Double.NaN if an error occurs.
    • getCellCount

      public int getCellCount(String columnName)
      Retrieves the total count of cells in a specific column.
      Parameters:
      columnName - the name of the column.
      Returns:
      the number of cells in the column, or 0 if an error occurs.
    • getCellCount

      public int getCellCount(int columnIndex)
      Retrieves the total count of cells in a specific column.
      Parameters:
      columnIndex - the name of the column.
      Returns:
      the number of cells in the column, or 0 if an error occurs.