Hello I am working on a CSV file using camel bindy component where I split data into 1000 line of chunks and its generating header columns with each chunks, I need it should generate only one time with single file. MyRoute:
final DataFormat inputCSV = new BindyCsvDataFormat(InputCSV.class);
final DataFormat outputCSV = new BindyCsvDataFormat(OutputCSV.class);
@Override
public void configure() throws Exception {
from("file:inbox/inputFile?fileName=inputProducts.csv&noop=true")
.split().tokenize("\\n", 1000)
.unmarshal(inputCSV)
.bean(Processor.class, "processCSV")
.marshal(outputCSV)
.to("file:inbox/outputFile?fileExist=append&fileName=outputProduct.csv");
}
And my OutputCSV.java pojo
@CsvRecord(separator = ",",generateHeaderColumns=true)
public class OutputCSV implements Serializable {
private static final long serialVersionUID = 1L;
@DataField(pos = 1, required = true)
private String product_id;
@DataField(pos = 2, required = true)
private String product_name;
//Getter and setter
}
My question is how do I make this code so it will generate header once for single file ?