Package org.supercsv.io

Examples of org.supercsv.io.ICsvMapReader


        }
        out.close();
    }

    public Object unmarshal(Exchange exchange, InputStream inputStream) throws Exception {
        ICsvMapReader reader = new CsvMapReader(new InputStreamReader(inputStream), preference);
        String[] headers = reader.getCSVHeader(true);
        List<Map<String, String>> list = new ArrayList<Map<String, String>>();
        try {
            while (true) {
                Map<String, String> map = reader.read(headers);
                if (map == null) {
                    break;
                }
                else {
                    list.add(map);
View Full Code Here


     *             the input-output exception
     */
    public static Map<String, List<Object>> readCSVFileToMap(final FileReader csvFileReader) throws IOException {
        CSVUtils.LOG.info(MethodUtils.executionMessage());
        Map<String, List<Object>> parsedData = null;
        ICsvMapReader csvMapReader = null;
        try {
            csvMapReader = new CsvMapReader(csvFileReader, CSVFeedConstants.PIPE_DELIMITED);
            final String[] headers = csvMapReader.getHeader(BooleanConstants.TRUE.getPrimitiveType());
            parsedData = GeneratorUtils.<String, List<Object>>generateDefaultEmptyHashMap();
            for (final String header : headers) {
                parsedData.put(header, GeneratorUtils.<Object>generateDefaultEmptyArrayList());
            }
            Map<String, Object> tempParsedData;
            while (null != (tempParsedData = csvMapReader.read(headers, CSVFeedConstants.PROCESSORS))) {
                for (final Entry<String, Object> entry : tempParsedData.entrySet()) {
                    parsedData.get(entry.getKey()).add(entry.getValue());
                }
            }
        } finally {
            if (null != csvMapReader) {
                csvMapReader.close();
            }
        }
        CSVUtils.LOG.info(MethodUtils.successMessage());
        CSVUtils.LOG.info(MethodUtils.callbackMessage(parsedData));
        return parsedData;
View Full Code Here

TOP

Related Classes of org.supercsv.io.ICsvMapReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.