You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by keepcl123 <ke...@gmail.com> on 2013/12/26 20:25:36 UTC

writing a csv file

Hi,

I want to read a csv file from the file directory into a java bean, do some
work on the data (a List) and then save the data to a new csv file.

I mange to do the first part (unmarshal) , but I don't know how to do the
part of writing the file after I finished my work on it (marshal ).
Here is my code , but I get en exception on the marshal part : "can not
convert from a String to a Map"


<bean id="csvReportsHandler" scope="singleton"
class="calypsox.reports.CsvReportsHandler" />
<camelContext xmlns="http://camel.apache.org/schema/spring"
id="report1">
<propertyPlaceholder id="reportsProperty"
location="BLLresources/reports.properties" />
<route>

<from
uri="file:{{report1.incoming.directory}}?preMove={{report1.inprogress.directory}}&amp;move=
{{report1.done.directory}}&amp;moveFailed={{report1.failed.directory}}" />
<unmarshal>
<csv />
</unmarshal>
<to uri="bean:csvReportsHandler?method=doHandleCsvData" />
<marshal>
<csv />
</marshal>

<to uri="file:{{report1.outcoming.directory}}?fileName=teat.csv" />
</route>
</camelContext>

Can you help ?
Thx



--
View this message in context: http://camel.465427.n5.nabble.com/writing-a-csv-file-tp5745260.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: writing a csv file

Posted by keepcl123 <ke...@gmail.com>.
  public void doHandleCsvData(List<List&lt;String>> csvData) { 
                        } 



--
View this message in context: http://camel.465427.n5.nabble.com/writing-a-csv-file-tp5745260p5745293.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: writing a csv file

Posted by keepcl123 <ke...@gmail.com>.
Also I would like to know how to get the .csv file name that I have read when
I am in my bean.



--
View this message in context: http://camel.465427.n5.nabble.com/writing-a-csv-file-tp5745260p5745287.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: writing a csv file

Posted by keepcl123 <ke...@gmail.com>.
here is the exception and my code :

the bean method :              



          public void doHandleCsvData(List<List&lt;String>> csvData) {
                        }



      the xml :
                        <bean id="csvReportsHandler" scope="singleton"
                        class="calypsox.reports.CsvReportsHandler" />
                        <camelContext
xmlns="http://camel.apache.org/schema/spring"
                        id="report1">
                        <propertyPlaceholder id="reportsProperty"
                        location="BLLresources/reports.properties" />
                        <route>

                       <from
                       
uri="file:{{report1.incoming.directory}}?preMove={{report1.inprogress.directory}}&amp;move=
                       
{{report1.done.directory}}&amp;moveFailed={{report1.failed.directory}}" />
                        <unmarshal>
                        <csv />
                        </unmarshal>
                        <to
uri="bean:csvReportsHandler?method=doHandleCsvData" />
                        <marshal>
                        <csv />
                        </marshal>
                        <to
uri="file:{{report1.outcoming.directory}}?fileName=teat.csv" />
                        </route>
                        </camelContext>

the exception is:

                        [LOG|ERROR|27 09:58:26,734 2013 דצמ
|org.apache.camel.processor.DefaultErrorHandler|Camel (report1) thread #1 -
                        file://C:reports1_in| - ]
                        Failed delivery for exchangeId:
ID-NTAS107703T05-50117-1388131078416-3-1. Exhausted after delivery attempt:
1 caught:
                        org.apache.camel.NoTypeConversionAvailableException:
No type converter available to convert from type: java.lang.String to
                        the required type: java.util.Map with value ILS
                        [END]
                        org.apache.camel.NoTypeConversionAvailableException:
No type converter available to convert from type: java.lang.String to
                        the required type: java.util.Map with value ILS
                        at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:144)
                        at
org.apache.camel.util.ExchangeHelper.convertToMandatoryType(ExchangeHelper.java:143)
                        at
org.apache.camel.dataformat.csv.CsvDataFormat.marshal(CsvDataFormat.java:70)
                        at
org.apache.camel.processor.MarshalProcessor.process(MarshalProcessor.java:57)
                        at
org.apache.camel.impl.converter.AsyncProcessorTypeConv



--
View this message in context: http://camel.465427.n5.nabble.com/writing-a-csv-file-tp5745260p5745286.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: writing a csv file

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

Can you show us the code of calypsox.reports.CsvReportsHandler?

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com(http://willemjiang.blogspot.com/) (English)
http://jnn.iteye.com(http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On December 27, 2013 at 3:26:04 AM, keepcl123 (keepcl123@gmail.com) wrote:
>  
> Hi,
>  
> I want to read a csv file from the file directory into a java bean,  
> do some
> work on the data (a List) and then save the data to a new csv file.  
>  
> I mange to do the first part (unmarshal) , but I don't know how to  
> do the
> part of writing the file after I finished my work on it (marshal  
> ).
> Here is my code , but I get en exception on the marshal part : "can  
> not
> convert from a String to a Map"
>  
>  
> > class="calypsox.reports.CsvReportsHandler" />
> > id="report1">
> > location="BLLresources/reports.properties" />
>  
>  
> > uri="file:{{report1.incoming.directory}}?preMove={{report1.inprogress.directory}}&move=  
> {{report1.done.directory}}&moveFailed={{report1.failed.directory}}"  
> />
>  
>  
>  
> > />
>  
>  
>  
>  
> > />
>  
>  
>  
> Can you help ?
> Thx
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/writing-a-csv-file-tp5745260.html  
> Sent from the Camel - Users mailing list archive at Nabble.com.  
>