Change CSV decimal separator in a Camel route
Most FA readers expect CSV files to use point as a decimal separator. If your file uses a different separator, you can change it by using Camel CSV decimal format change processor included in FA Connector.
To use the processor in your Camel route:
Set the following headers:
CamelCSVOriginalDecimalSeparatorand the original CSV separator as its value.CamelCSVNewDecimalSeparatorand the new CSV separator as its value.CamelCSVFieldsToReplaceand the fields you want the change to apply to as its value.
Transform the CSV message into a list of maps by unmarshalling with
useMapsoption set totrue.Call the
csvDecimalFormatChangeProcessorprocess.Transform the list of maps back into CSV by marshalling with
useMapsset totrue.
Example of using CSV decimal format change processor
<setHeader name="CamelCSVOriginalDecimalSeparator"> <simple> <![CDATA[,]]> </simple> </setHeader> <setHeader name="CamelCSVNewDecimalSeparator"> <simple> <![CDATA[.]]> </simple> </setHeader> <setHeader name="CamelCSVFieldsToReplace"> <simple> <![CDATA[amount]]> </simple> </setHeader> <unmarshal><csv useMaps="true" delimiter=";"/></unmarshal> <process ref="csvDecimalFormatChangeProcessor"/> <marshal><csv useMaps="true" delimiter=";"/></marshal>