All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openmrs.module.rulesengine.util.CSVReader Maven / Gradle / Ivy

package org.openmrs.module.rulesengine.util;

import org.bahmni.csv.CSVEntity;
import org.bahmni.csv.CSVFile;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class CSVReader {

    public List readCsvFileToMemory(CSVFile csvFile, Class entityClass) {
        try {
            T csvEntity;
            List csvRowsFromFile = new ArrayList<>();
            csvFile.openForRead();
            while ((csvEntity = (T) csvFile.readEntity(entityClass)) != null) {
                csvRowsFromFile.add(csvEntity);
            }
            return csvRowsFromFile;
        } catch (IOException | InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
        }
        return null;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy