Documentation of 'org.supercsv.io.CsvMapReader' Java class
CsvMapReader
org.supercsv.io

Class CsvMapReader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, ICsvMapReader, ICsvReader


    public class CsvMapReader
    extends AbstractCsvReader
    implements ICsvMapReader
    CsvMapReader reads each CSV row into a Map with the column name as the map key, and the column value as the map value.
    • Constructor Summary

      Constructors 
      Constructor and Description
      CsvMapReader(ITokenizer tokenizer, CsvPreference preferences)
      Constructs a new CsvMapReader with the supplied (custom) Tokenizer and CSV preferences.
      CsvMapReader(java.io.Reader reader, CsvPreference preferences)
      Constructs a new CsvMapReader with the supplied Reader and CSV preferences.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.util.Map<java.lang.String,java.lang.String> read(java.lang.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.
      java.util.Map<java.lang.String,java.lang.Object> read(java.lang.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 class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.io.Closeable

        close
    • Constructor Detail

      • CsvMapReader

        public CsvMapReader(java.io.Reader reader,
                            CsvPreference preferences)
        Constructs a new CsvMapReader with the supplied Reader and CSV preferences. Note that the reader will be wrapped in a BufferedReader before accessed.
        Parameters:
        reader - the reader
        preferences - the CSV preferences
        Throws:
        java.lang.NullPointerException - if reader or preferences are null
      • CsvMapReader

        public CsvMapReader(ITokenizer tokenizer,
                            CsvPreference preferences)
        Constructs a new CsvMapReader with the supplied (custom) Tokenizer and CSV preferences. The tokenizer should be set up with the Reader (CSV input) and CsvPreference beforehand.
        Parameters:
        tokenizer - the tokenizer
        preferences - the CSV preferences
        Throws:
        java.lang.NullPointerException - if tokenizer or preferences are null
    • Method Detail

      • read

        public java.util.Map<java.lang.String,java.lang.String> read(java.lang.String... nameMapping)
                                                              throws java.io.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.
        Specified by:
        read in interface ICsvMapReader
        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:
        java.io.IOException - if an I/O error occurred
      • read

        public java.util.Map<java.lang.String,java.lang.Object> read(java.lang.String[] nameMapping,
                                                                     CellProcessor[] processors)
                                                              throws java.io.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.
        Specified by:
        read in interface ICsvMapReader
        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:
        java.io.IOException - if an I/O error occurred

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.