Hi Claus,
The following example of commons-csv demonstrates taking input delimited by
comma and writing output delimited by pipe.
import java.io.Reader;
import java.io.StringReader;
import org.apache.commons.csv.CSVParser;
import org.apache.commons.csv.CSVPrinter;
import org.apache.commons.csv.CSVStrategy;
public class TestCsv {
/**
* @param args the command line arguments
* @throws Exception
*/
public static void main(String[] args) throws Exception {
Reader reader = new StringReader("abc,123,def,456,ghi,789");
CSVStrategy csvStrategy = new CSVStrategy(',', '"', '#');
CSVParser csvParser = new CSVParser(reader, csvStrategy);
String[] parsedLine = csvParser.getLine();
for (int i = 0; i < parsedLine.length; ++i) {
System.out.println("value " + i + "=" + parsedLine[i]);
}
CSVPrinter csvPrinter = new CSVPrinter(System.out);
csvStrategy.setDelimiter('|');
csvPrinter.setStrategy(csvStrategy);
csvPrinter.println(parsedLine);
}
}
Claus Ibsen-2 wrote:
>
> Hi
>
> Try to create an unit test with pure Commons CSV to see what it takes
> to have it output with a delimiter of your choice.
> Then we can see what is missing in Camel.
>
>
--
View this message in context:
http://old.nabble.com/marshal-to-CSV-with-pipe-delimiter-tp28842183p28889019.html
Sent from the Camel - Users mailing list archive at Nabble.com.