Beispiel #1
0
 private void initializeCSVReader(FunctionContext context) throws IOException {
   this.csvReader = new CSVReader(new FileReader(context.getParameterAsString(IP_CSV_FILE)));
   this.headers = csvReader.readNext();
   if (headers == null) {
     throw new RuntimeException("no data found in input csv file");
   }
 }
Beispiel #2
0
 @Override
 public void execute(FunctionContext context) throws Exception {
   String[] csvParameters = this.csvReader.readNext();
   if (csvParameters == null) {
     csvReader.close();
     initializeCSVReader(context);
     csvParameters = this.csvReader.readNext();
   }
   if (csvParameters != null) {
     for (int headerI = 0; headerI < headers.length; headerI++) {
       context.addParameter(headers[headerI], csvParameters[headerI]);
     }
   }
 }