Class CSVConversion


  • public final class CSVConversion
    extends java.lang.Object
    Conversion from CSV to a structure like XES. Use doConvertCSVToXES(ProgressListener, CSVFile, CSVConfig, CSVConversionConfig) to convert to XES, use convertCSV(ProgressListener, CSVConfig, CSVConversionConfig, CSVFile, CSVConversionHandler) to use your own CSVConversionHandler for some other format.

    Example usage:

     CSVFileReferenceUnivocityImpl csvFile = new CSVFileReferenceUnivocityImpl(getFile().toPath());
     CSVConfig config = new CSVConfig(csvFile);
     try (ICSVReader reader = csvFile.createReader(config)) {
            CSVConversion conversion = new CSVConversion();
            CSVConversionConfig conversionConfig = new CSVConversionConfig(csvFile, config);
            conversionConfig.autoDetect();
     
            conversionConfig.setCaseColumns(ImmutableList.of("case"));
            conversionConfig.setEventNameColumns(ImmutableList.of("event"));
            conversionConfig.setCompletionTimeColumn("time");
            conversionConfig.setEmptyCellHandlingMode(CSVEmptyCellHandlingMode.SPARSE);
            conversionConfig.setErrorHandlingMode(CSVErrorHandlingMode.ABORT_ON_ERROR);
            Map<String, CSVMapping> conversionMap = conversionConfig.getConversionMap();
            CSVMapping mapping = conversionMap.get("time");
            mapping.setDataType(Datatype.TIME);
            mapping.setPattern("yyyy/MM/dd");
     
            ConversionResult<XLog> result = conversion.doConvertCSVToXES(new NoOpProgressListenerImpl(), csvFile, config,
                            conversionConfig);
     
            XLog log = result.getResult();
     }
     
    Author:
    F. Mannhardt