Author |
Message
|
farubino |
Posted: Tue Mar 17, 2009 4:23 am Post subject: CSV question |
|
|
Novice
Joined: 17 Mar 2009 Posts: 13
|
Hi,
i am a newbie of Message Broker. I have a flow with a csv input message. All data inside the csv are separated by a pipe('|').
The problem is that records are not in the same row in the csv. Each record can be splitted into two rows. So, it's difficult to understand if the current row parsed is a new record or is refered to the former one.
I thougth to use regular expression (Data pattern separation types) to parse the file, but i don't know if is the right choose.
This is an example of a record in my csv:
Code: |
data1|data2|data3|address1|address2|address3|<CR><LF>address4|address5|
data1|data2|data3|address1|address2
data1|data2|data3|address1|address2|address3|<CR><LF>address4|address5|address6|
|
Thanks in advance |
|
Back to top |
|
 |
Vitor |
Posted: Tue Mar 17, 2009 4:37 am Post subject: Re: CSV question |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
farubino wrote: |
i am a newbie of Message Broker. I have a flow with a csv input message. All data inside the csv are separated by a pipe('|'). |
So you have Comma Separated Values with no commas?
farubino wrote: |
The problem is that records are not in the same row in the csv. Each record can be splitted into two rows. |
So potentially there's a CR/LF embedded in a row, as well as marking the end of it? Yes?
What is producing this message? What rule(s) does it use for breaking the row like this? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Mar 17, 2009 5:02 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Is there something unique about data1? |
|
Back to top |
|
 |
farubino |
Posted: Tue Mar 17, 2009 5:05 am Post subject: |
|
|
Novice
Joined: 17 Mar 2009 Posts: 13
|
I have done a mistake. Data in my file are separated by tag. The separator is the pipe "|".
Each record in the file identifies a person and his home addresses.
If a person has more than 5 addresses, the related record is splitted into 2 rows. The first row contains the following data:
personid|name|surname|address1|address2|address3|address4|address5
The second row contains the others addresses
address6|address7|...|addressN
I hope i'm clear.
Thanks |
|
Back to top |
|
 |
kimbert |
Posted: Tue Mar 17, 2009 5:38 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
I don't see any tag in your data. I see pipe-separated fields.
It looks to me as if you have two kinds of line
PersonRecord, with between 4 and 8 fields separated by a pipe
ExtraAddresses, with 1..N fields. If N is always < 4 then your problem is simple. Use data patterns to detect fields which have >= 4 fields. Put both of your fields into a choice with DES="Use Data Pattern". The members of the choice will be elements 'PersonRecord' and 'ExtraAddresses' with the choice having DES="All Elements Delimited".
If ExtraAddresses can have 4 fields or more, you need a way to detect personId using a data pattern.
Please remember that the data patterns on PersonRecord and ExtraAddresses *must* match the entire line. Otherwise the group underneath the data pattern will run out of data. |
|
Back to top |
|
 |
farubino |
Posted: Tue Mar 17, 2009 6:01 am Post subject: |
|
|
Novice
Joined: 17 Mar 2009 Posts: 13
|
Thanks...i'll try in this way |
|
Back to top |
|
 |
|