CARVIEW |
Select Language
HTTP/2 200
server: GitHub.com
content-type: text/html; charset=utf-8
last-modified: Thu, 29 Oct 2015 19:20:12 GMT
access-control-allow-origin: *
etag: W/"5632716c-61c2"
expires: Tue, 22 Jul 2025 10:02:41 GMT
cache-control: max-age=600
content-encoding: gzip
x-proxy-cache: MISS
x-github-request-id: BAEE:1E1776:4658F:4DEDE:687F5F69
accept-ranges: bytes
age: 0
date: Tue, 22 Jul 2025 09:52:41 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210025-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1753177961.051513,VS0,VE236
vary: Accept-Encoding
x-fastly-request-id: ac941b0937698670af5e5403ac66a7839d035b18
content-length: 3981
CsvMapReader (Super CSV 2.4.0 API)
org.supercsv.io
Class CsvMapReader
- java.lang.Object
-
- org.supercsv.io.AbstractCsvReader
-
- org.supercsv.io.CsvMapReader
-
- All Implemented Interfaces:
- Closeable, 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.- Author:
- Kasper B. Graversen, James Bassett
-
-
Constructor Summary
Constructors Constructor and Description CsvMapReader(ITokenizer tokenizer, CsvPreference preferences)
Constructs a new CsvMapReader with the supplied (custom) Tokenizer and CSV preferences.CsvMapReader(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 Map<String,String>
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.Map<String,Object>
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 class org.supercsv.io.AbstractCsvReader
close, executeProcessors, get, getColumns, getHeader, getLineNumber, getPreferences, getRowNumber, getUntokenizedRow, length, readRow
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.supercsv.io.ICsvReader
get, getHeader, getLineNumber, getRowNumber, getUntokenizedRow, length
-
-
-
-
Constructor Detail
-
CsvMapReader
public CsvMapReader(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 readerpreferences
- the CSV preferences- Throws:
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 tokenizerpreferences
- the CSV preferences- Throws:
NullPointerException
- if tokenizer or preferences are null
-
-
Method Detail
-
read
public 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.- Specified by:
read
in interfaceICsvMapReader
- 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
-
read
public 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.- Specified by:
read
in interfaceICsvMapReader
- 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
-
-
Copyright © 2007–2015 Super CSV. All rights reserved.