java.lang.Object
io.github.astrapisixtynine.csv.CsvExtensions

public class CsvExtensions extends Object
The CsvExtensions class provides utility methods to read data from CSV files, map the data to objects, and generate maps of data from lists of objects. This class supports reading CSV files using Apache Commons CSV and creating data structures like lists and maps from the parsed CSV data
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    static <T> List<T>
    readEntriesFromCsv(File csvFile, Function<org.apache.commons.csv.CSVRecord,T> recordMapper)
    Reads entries from a CSV file, processes each record using a provided mapper function, and returns a list of mapped entries
    static <T> List<T>
    readEntriesFromCsv(InputStream csvInputStream, Function<org.apache.commons.csv.CSVRecord,T> recordMapper)
    Reads entries from a CSV input stream, processes each record using a provided mapper function, and returns a list of mapped entries
    static void
    sortCsv(Path csvFilePath, Supplier<Comparator<String[]>> comparatorSupplier)
    Reads a CSV file, sorts its data based on a supplied comparator, and writes the sorted data back to the file.
    static void
    Reads a CSV file, sorts its data by 'algorithm' and 'keysize' in ascending order, and writes the sorted data back to the file
    static void
    Sorts a CSV file by 'keypair-algorithm' and 'signature-algorithm', removes duplicates, and rewrites the sorted data back to the CSV file

    Von Klasse geerbte Methoden java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Methodendetails

    • sortCsvByKeypairAndSignatureAlgorithm

      public static void sortCsvByKeypairAndSignatureAlgorithm(Path csvFilePath) throws IOException
      Sorts a CSV file by 'keypair-algorithm' and 'signature-algorithm', removes duplicates, and rewrites the sorted data back to the CSV file
      Parameter:
      csvFilePath - the path to the CSV file to be sorted
      Löst aus:
      IOException - if an I/O error occurs
    • sortCsv

      public static void sortCsv(Path csvFilePath, Supplier<Comparator<String[]>> comparatorSupplier) throws IOException
      Reads a CSV file, sorts its data based on a supplied comparator, and writes the sorted data back to the file.
      Parameter:
      csvFilePath - the path to the CSV file to be sorted
      comparatorSupplier - a supplier that provides a comparator for sorting the rows
      Löst aus:
      IOException - if an I/O error occurs
    • sortCsvByAlgorithmAndKeysize

      public static void sortCsvByAlgorithmAndKeysize(Path csvFilePath) throws IOException
      Reads a CSV file, sorts its data by 'algorithm' and 'keysize' in ascending order, and writes the sorted data back to the file
      Parameter:
      csvFilePath - the path to the CSV file to be sorted
      Löst aus:
      IOException - if an I/O error occurs
    • readEntriesFromCsv

      public static <T> List<T> readEntriesFromCsv(InputStream csvInputStream, Function<org.apache.commons.csv.CSVRecord,T> recordMapper) throws IOException
      Reads entries from a CSV input stream, processes each record using a provided mapper function, and returns a list of mapped entries
      Typparameter:
      T - the generic type of the returned entries
      Parameter:
      csvInputStream - the input stream of the CSV file
      recordMapper - a function that maps each CSV record to an object of type T
      Gibt zurück:
      a list of mapped entries of type T
      Löst aus:
      IOException - if an I/O error occurs
    • readEntriesFromCsv

      public static <T> List<T> readEntriesFromCsv(File csvFile, Function<org.apache.commons.csv.CSVRecord,T> recordMapper) throws IOException
      Reads entries from a CSV file, processes each record using a provided mapper function, and returns a list of mapped entries
      Typparameter:
      T - the generic type of the returned entries
      Parameter:
      csvFile - the CSV file to read from
      recordMapper - a function that maps each CSV record to an object of type T
      Gibt zurück:
      a list of mapped entries of type T
      Löst aus:
      IOException - if an I/O error occurs