Author |
Message
|
usr_12345 |
Posted: Fri Apr 01, 2016 7:07 am Post subject: write xml to csv |
|
|
Novice
Joined: 14 May 2013 Posts: 11
|
Hi, i'm reading an xml file and want record it to a csv.
xml:
<a>
<b1>content1</b1>
</a>
csv:
<b1>content1</b1>,123
I'm able to write xml content but not add other column to the csv:
<b1>content1</b1>
I converted the read xmlnsc value to blob and then to char to append the second column value, but that doesn't seem to be working. Any ideas? |
|
Back to top |
|
 |
Vitor |
Posted: Fri Apr 01, 2016 7:17 am Post subject: Re: write xml to csv |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
usr_12345 wrote: |
I converted the read xmlnsc value to blob and then to char to append the second column value, but that doesn't seem to be working. Any ideas? |
Well call me crazy but how about you use the DFDL CSV model and create your CSV with that?
Do you really want the XML tag and it's content? What the contact admin is the requirement here? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
usr_12345 |
Posted: Fri Apr 01, 2016 7:19 am Post subject: |
|
|
Novice
Joined: 14 May 2013 Posts: 11
|
Yes i do need xml tags because they are actually complex types, i have put them that as a sample. |
|
Back to top |
|
 |
Vitor |
Posted: Fri Apr 01, 2016 7:20 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
usr_12345 wrote: |
Yes i do need xml tags because they are actually complex types, i have put them that as a sample. |
Ok, so my question become why are you passing complex types as a CSV structure? What's the requirement? What's consuming the file and if it can parse XML complex types from a CSV, why can't it parse the XML and avoid the CSV?
My advice remains unchanged. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
usr_12345 |
Posted: Fri Apr 01, 2016 7:24 am Post subject: |
|
|
Novice
Joined: 14 May 2013 Posts: 11
|
The requirement is to read an xml coming from outside IB world conditionally write the inner child xml elements as is to a file, so that the file can be reread and reprocessed later.
FileInput is reading the xml file and writing to FileOutput node. |
|
Back to top |
|
 |
Vitor |
Posted: Fri Apr 01, 2016 7:46 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
usr_12345 wrote: |
The requirement is to read an xml coming from outside IB world conditionally write the inner child xml elements as is to a file, so that the file can be reread and reprocessed later.
FileInput is reading the xml file and writing to FileOutput node. |
This is no way answers my question.
Why does the XML need to be broken up into a CSV file? To be processed (or reprocessed) the complex types that make it up have to be parsed as XML. Why not then simply preserve the original file, possibly removing those child elements that are not required (you mentioned conditionally writing inner child elements)?
I don't see the point of this process.
I still stand by my advice on how to achieve it. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
usr_12345 |
Posted: Fri Apr 01, 2016 8:14 am Post subject: |
|
|
Novice
Joined: 14 May 2013 Posts: 11
|
I need to maintain the count of retry per record, for that i'm adding the count as a column. I only want to reprocess x number of times. Thats the only reason i want to make it a csv. |
|
Back to top |
|
 |
Vitor |
Posted: Fri Apr 01, 2016 8:16 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
usr_12345 wrote: |
I need to maintain the count of retry per record, for that i'm adding the count as a column. I only want to reprocess x number of times. Thats the only reason i want to make it a csv. |
And you felt that adding the count as a new tag (or better still an attribute of the parent tag) was much harder than turning it into a csv and then turning it back into XML?
Weird, weird design. But it's your weird design not mine. Go forth in peace and may it bring you joy.
I still stand by my advice for creating the CSV. _________________ Honesty is the best policy.
Insanity is the best defence.
Last edited by Vitor on Fri Apr 01, 2016 8:30 am; edited 1 time in total |
|
Back to top |
|
 |
usr_12345 |
Posted: Fri Apr 01, 2016 8:21 am Post subject: |
|
|
Novice
Joined: 14 May 2013 Posts: 11
|
ok, i rest my case
Will look at other options. Thank you. |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Apr 01, 2016 8:35 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
What do you mean "only reprocess it a certain number of times" ? Retry what? The input of the message, or the output of the message?
What is doing the retry? Your Flow? the sending application? the receiving application?
What do you mean "record it as a csv"? Where? _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
timber |
Posted: Fri Apr 01, 2016 8:54 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Quote: |
I converted the read xmlnsc value to blob and then to char to append the second column value, but that doesn't seem to be working. Any ideas? |
So you are trying to write a CSV file from IIB and you are not using DFDL. That is very, very poor quality work. It is usually a bad idea to try to write your own parser or writer for a data format. If the data format is CSV then it is plain crazy.
I also agree with Vitor; embedding snippets of XML inside a CSV file is a poor design choice. I suggest that you stop and think about the real requirements before you continue. |
|
Back to top |
|
 |
|