Import CSV as Cases
The Import CSV application is runnable in the Demo environment or in your own instance of .
To learn how to install NAE CE locally or on a server, follow this tutorial.
CSV pom dependency
XML
<!--CSV pom-->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.6</version>
</dependency>CSV parser code snippet
groovy
import org.apache.commons.csv.*
void importCSVFile(FileField file, String net, List fields) {
try {
def stream = new FileInputStream(new File(file.value.path))
CSVParser parser = CSVParser.parse(stream, Charset.forName("UTF-8"), CSVFormat.EXCEL.withDelimiter(',' as char))
for (CSVRecord record in parser.iterator()) {
def cas = createCase(net, record[0])
fields.eachWithIndex { String entry, int i ->
cas.getDataField(entry).setValue(record[i])
}
workflowService.save(cas)
}
} catch (Exception e) {
log.error("Import CSV File error", e)
}
}Click here to launch the Mobile process in Builder
