|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
CSV Message Modelling |
« View previous topic :: View next topic » |
Author |
Message
|
hayder |
Posted: Wed Apr 17, 2013 1:54 am Post subject: CSV Message Modelling |
|
|
Newbie
Joined: 17 Apr 2013 Posts: 2
|
Hi all,
I am using MB 6.1.0.11. I have a requirement to parse a csv file in my message flow. I am reading a csv file as a blob and parsing it using a defined message set through a resetContentDescriptor node. I ran into some problems with the CSV file. Below is the example of what I receive:
Header_1, Header_2, Header_3, Header_4 <CR><LF>
"a","b", "c", "d" <CR><LF>
"aa","bb","cc "hello there" cc","dd" <CR><LF>
When my message set parses this message, I get MRM parser error when it hits the 3nd line. This is because the double quotes (") the filed contains. My message Set is dealing with double quotes at the beginning and end of each field as expected. But it is getting confused when it hits the double quotes in the middle of the field. I am not that familiar with Message Sets and was hoping if someone can help me
My message Set setting:
Quote Char: "
Reserved Char: ,<CR><LF>"
Thank you
Hayder |
|
Back to top |
|
 |
kimbert |
Posted: Wed Apr 17, 2013 3:10 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
|
Back to top |
|
 |
hayder |
Posted: Wed Apr 17, 2013 3:23 pm Post subject: |
|
|
Newbie
Joined: 17 Apr 2013 Posts: 2
|
Thank you Kimbert for your response
The Escape Char is disabled (because I am using the Quote Char)
The Qutoe char is set to " (double quote)
However, when it hits the line with the double quote within the data field, the message set throughs an exception (Parser errr exception). How Can I tell my parser to ignore the double quotes in the data field?
I am using the standard CSV message set in MB 6.1.0.11
Thank you for your help
Hayder |
|
Back to top |
|
 |
kimbert |
Posted: Thu Apr 18, 2013 12:23 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Ah - sorry. I should have read your first post more carefully.
If the quote character appears within the value of a field then it should be escaped. The standard way to do this is to double the quote character. Like this:
Code: |
"a","b", "c", "d" <CR><LF>
"aa","bb","cc ""hello there"" cc","dd" <CR><LF> |
If you cannot change the format of the incoming data then you may have to try one of the following:
a) remove the quote character. The field values will contain the leading and trailing quotes, so you will need to write a simple function to remove them
b) fix up the incoming data; double any quote characters that are not preceded by a comma or followed by a comma. You can do this by parsing in the BLOB domain, converting to CHARACTER and then using ESQL's string manipulation routines. Or Java's, if you prefer. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|