camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem jiang <willem.ji...@gmail.com>
Subject Re: way to convert multiple csv files to single xml file
Date Thu, 09 Aug 2012 08:16:31 GMT
Did you have a look at the Aggregator[1]?
I think it can resolve the issue that you meet.

[1]http://camel.apache.org/aggregator.html 

-- 
Willem Jiang

FuseSource
Web: http://www.fusesource.com (http://www.fusesource.com/)
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang 
Weibo: willemjiang



On Thursday, August 9, 2012 at 3:15 PM, Matheen wrote:

> Hi All, 
> 
> i am trying my hands on camel where i have to fetch some csv files from a 
> file system and needs to convert it to xml format and place it on some other 
> system 
> here is my sample code
> 
> package com.softedge.camel.java.xtof;
> 
> import org.apache.camel.CamelContext;
> import org.apache.camel.RoutesBuilder;
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.dataformat.bindy.csv.*;
> import org.apache.camel.impl.DefaultCamelContext;
> import org.apache.camel.spi.DataFormat;
> 
> public class ConvertorRoute implements RoutesBuilder{
> 
> @Override
> public void addRoutesToCamelContext(CamelContext context) throws Exception {
> context.addRoutes(new RouteBuilder() {
> public void configure() {
> try {
> DataFormat bindy = new BindyCsvDataFormat("com.softedge.dto");
> DataFormat bindy1 = new BindyCsvDataFormat("com.softedge.dto");
> from("file://TEST?fileName=order.csv&noop=true").
> unmarshal(bindy).
> marshal().
> xstream().
> to("file://TESTOUT?fileName=order.xml");
> from("file://TEST?fileName=order_line.csv&noop=true").
> unmarshal(bindy1).
> marshal().
> xstream().
> to("file://TESTOUT?fileName=orderLine.xml");
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> });
> }
> 
> public static void main(String[] args) { 
> try{
> CamelContext context = new DefaultCamelContext();
> ConvertorRoute route = new ConvertorRoute();
> route.addRoutesToCamelContext(context);
> context.start();
> Thread.sleep(5000);
> context.stop();
> }catch(Exception exe){
> exe.printStackTrace();
> }
> 
> but now i have a scenario like i have to convert multiple Csv files
> order,order_Line to single xml file.
> the data in the XML should be appended data from both csv file order and
> order_lines.
> 
> thanks
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/way-to-convert-multiple-csv-files-to-single-xml-file-tp5717048.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




Mime
View raw message