Package com.shaft.tools.io
Class CSVFileManager
java.lang.Object
com.shaft.tools.io.CSVFileManager
- Direct Known Subclasses:
SHAFT.TestData.CSV
-
Constructor Summary
ConstructorsConstructorDescriptionCSVFileManager
(String csvFilePath) Creates a new instance of the test data CSV reader using the target CSV file path -
Method Summary
Modifier and TypeMethodDescriptionint
getCellCount
(int columnIndex) Retrieves the total count of cells in a specific column.int
getCellCount
(String columnName) Retrieves the total count of cells in a specific column.getCellData
(int RowNum, int ColumnIndex) Retrieves a specific cell's data based on row number and column name.getCellData
(int RowNum, String ColumnName) Retrieves a specific cell's data based on row number and column name.Retrieves the column names from the CSV file.Maps each column name to its corresponding list of row data.Retrieves the name of the first column in the CSV file.Retrieves the name of the last column in the CSV file.double
getMaxCellValue
(int columnIndex) Retrieves the maximum value from a specific column.double
getMaxCellValue
(String columnName) Retrieves the maximum value from a specific column.double
getMinCellValue
(int columnIndex) Retrieves the minimum value from a specific column.double
getMinCellValue
(String columnName) Retrieves the minimum value from a specific column.getRows()
Retrieves all rows from the CSV file as a list of string arrays.getSpecificColumnData
(int ColumnIndex) Retrieves all data for a specific column.getSpecificColumnData
(String ColumnName) Retrieves all data for a specific column.getSpecificColumnName
(int ColumnNum) Retrieves the name of a specific column based on its index.
-
Constructor Details
-
CSVFileManager
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
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
Retrieves the column names from the CSV file.- Returns:
- a list of column names as strings.
-
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
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
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
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
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
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
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
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
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
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
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.
-