Interface ICsvMapReader

All Superinterfaces:
AutoCloseable, Closeable, ICsvReader
All Known Implementing Classes:
CsvMapReader

public interface ICsvMapReader extends ICsvReader
The interface for MapReaders, which read each CSV row into a Map.
  • Method Summary

    Modifier and Type
    Method
    Description
    read(String... nameMapping)
    Reads a row of a CSV file into a Map, using the supplied name mapping to map column values to the appropriate map entries.
    read(String[] nameMapping, CellProcessor[] processors)
    Reads a row of a CSV file into a Map, using the supplied name mapping to map column values to the appropriate map entries, and the supplied processors to process the values before adding them to the Map.

    Methods inherited from interface java.io.Closeable

    close

    Methods inherited from interface org.supercsv.io.ICsvReader

    get, getHeader, getLineNumber, getRowNumber, getUntokenizedRow, length
  • Method Details

    • read

      Map<String,String> read(String... nameMapping) throws IOException
      Reads a row of a CSV file into a Map, using the supplied name mapping to map column values to the appropriate map entries.
      Parameters:
      nameMapping - an array of Strings linking the CSV columns to their corresponding entry in the Map (the array length should match the number of columns). A null entry in the array indicates that the column should be ignored (e.g. not added to the Map).
      Returns:
      a Map of column names to column values (Strings, as no processing is performed), or null if EOF
      Throws:
      IOException - if an I/O error occurred
      NullPointerException - if nameMapping is null
      SuperCsvException - if there was a general exception while reading/processing
      Since:
      1.0
    • read

      Map<String,Object> read(String[] nameMapping, CellProcessor[] processors) throws IOException
      Reads a row of a CSV file into a Map, using the supplied name mapping to map column values to the appropriate map entries, and the supplied processors to process the values before adding them to the Map.
      Parameters:
      nameMapping - an array of Strings linking the CSV columns to their corresponding entry in the Map (the array length should match the number of columns). A null entry in the array indicates that the column should be ignored (e.g. not added to the Map).
      processors - an array of CellProcessors used to further process data before it is added to the Map (each element in the processors array corresponds with a CSV column - the number of processors should match the number of columns). A null entry indicates no further processing is required (the unprocessed String value will added to the Map).
      Returns:
      a Map of column names to column values, or null if EOF
      Throws:
      IOException - if an I/O error occurred
      NullPointerException - if nameMapping or processors are null
      SuperCsvConstraintViolationException - if a CellProcessor constraint failed
      SuperCsvException - if there was a general exception while reading/processing
      Since:
      1.0