cancel
Showing results for 
Search instead for 
Did you mean: 

Reading CSV file using Message Transforom Bean

0 Kudos

Hi All,

I was working on SFTP adapter which picks the CSV file that needs to convert into XML. So i am using Message Transform Bean module for conversion. PI version is 7.31 dual stack.

Below are the config done in channel.

When the channel is picked the file payload is looks like below.

The channel was reading the filed names from the CSV file. I want to ignore that and also there is "" symbol for the values that needs to be ignore. So please suggest to resolve this.

Regards,

Raju

Accepted Solutions (0)

Answers (1)

Answers (1)

Ryan-Crosby
Active Contributor
0 Kudos

HI Raju,

Add xml.enclosureSign = " for it to remove the double quotes around each field. As far as the header stuff you are getting information from the structure based upon the key xml.processFieldNames = fromConfiguration. That is instructing the MTB to read the data from your configuration so you should not observe any case where it is reading from the file itself.

Regards,

Ryan Crosby

0 Kudos

Hi Ryan,

Thanks for the reply. How to ignore the header line from file. Header line contains the field names.

Regards,

Raju

Ryan-Crosby
Active Contributor
0 Kudos

Hi Raju,

You could try xml.documentSkipFirstRows = 1 to see if it ignores the header line. If that does not work for the SimplePlain2XML then you would have to handle that in some type of mapping or request that the header line be dropped from the source.

Regards,

Ryan Crosby

0 Kudos

Thanks Ryan for the response. Now the " was removed from the data. But now " was coming in the nodes.

Example: <"Form Template ID">321</"Form Template ID">

How to remove the " from the tag. Please respond asap.

Ryan-Crosby
Active Contributor
0 Kudos

Hi Raju,

Can you share a screenshot of your current MTB configuration?

Regards,

Ryan Crosby

Ryan-Crosby
Active Contributor
0 Kudos

Hi Raju,

Also, you can try adding xml.enclosureSignEsc = "" into your configuration but not sure if that impacts node names. That should be reflected from the value in xml.fieldNames.

Regards,

Ryan Crosby

0 Kudos

Above is the configuration from the channel

0 Kudos

I have tried as suggested. But it didn't worked out.

Ryan-Crosby
Active Contributor
0 Kudos

Hi Raju,

Change your configuration on the xml.processFieldNames from "fromFile" to "fromConfiguration" and switch xml.documentSkipFirstRows = 1. If you intend to keep the header with the "fromFile" option then you would need to remove the " characters from the header line in the file.

Regards,

Ryan Crosby

0 Kudos

Hi Ryan,

I have tried as suggested by you. Now the " removed. But field names from the files is also coming in payload which should be ignored.

used xml.documentSkipFirstRows = 1.

Regards,

Raju

Ryan-Crosby
Active Contributor
0 Kudos

Hi Raju,

It appears that that parameter xml.documentSkipFirstRows does not work for SimplePlain2XML so you would have to suppress it in a mapping or use StructPlain2XML instead.

Regards,

Ryan Crosby

0 Kudos

Could you please share any link which specifies the StructPlain2XML

Ryan-Crosby
Active Contributor
0 Kudos

Hi Raju,

I would refer to this blog by Eng Swee: MTB Blog

Regards,

Ryan Crosby