Author |
Message
|
olafbey |
Posted: Thu Nov 01, 2007 6:20 am Post subject: CSV with appended spaces |
|
|
Newbie
Joined: 16 Dec 2006 Posts: 3
|
Hello all,
i have to develop a csv message model, where each record has a fixed length of 698 characters. This means, i have to append blanks for each record.
e.g.
"AAA","BBB","CC"<CR>
"AA","BB","CCC" <CR>
"AAAA","B","" <CR>
The development of the csv message model in the tds domain was easy, it works fine so far. But appending blanks in the tds domain seems to be impossible, because the elements are all of variable length.
Do i have to use the cwf domain with a new message definition in a second step?
Your help would be really appreciated.
Olaf |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Nov 01, 2007 6:27 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
There's a CSV sample that comes with V6. It should tell you how to do this.
Also, you're not talking about "appended spaces", you're talking about NULL valued or missing elements. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
olafbey |
Posted: Thu Nov 01, 2007 8:39 am Post subject: Re: fixed length records with variable length elements |
|
|
Newbie
Joined: 16 Dec 2006 Posts: 3
|
Hello Jeff,
thanks a lot for your quick reply. Sorry, but my explanation seems a bit inaccurate.
i have to write records in a file as csv. This works perfect, as described in the samples. Each element is delimited by commas and has a variable length, so the resulting record has a variable length too. Furthermore, some elements accept null values. up to this point everything is working fine.
The point is, the application reading the file expects a fixed record length of 698 characters. To achieve this I have to fill up the record at the end with spaces up to the total length of 698 characters.
i read the csv samples, but there is no hint or example that covers the problem as described.
Olaf |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Nov 01, 2007 8:46 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Ah, yes.
Okay.
I have a couple of thoughts on how this might be done.. but I'm not sure enough of them off the top of my head to mention. I've got some time, so lemme play with this and see.
If nothing else, I know you can do this by using ASBITSTREAM to serialize the message, and then manually padding each record by working with BLOB data. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
EddieA |
Posted: Thu Nov 01, 2007 8:47 am Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
You would have to force the output to be serialised, with ASBITSTREAM, and then add the required spaces to the resultant BLOB.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
kimbert |
Posted: Thu Nov 01, 2007 8:54 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
hi,
TDS can pad individual fixed length fields. If you tick 'Observe Element Length' it can even pad individual delimited fields . But it cannot pad the contents of a complex type. Unfortunately, that's what you need
You could probably do what you require like this ( not tested):
- Create a message definition 'OneLine' for a single line of delimited fields
In a loop in your Compute node
- Use ASBITSTREAM with message type 'OneLine' to create a BLOB variable
- Pad the line to the required length using ESQL
- Create LASTCHILD of OutputRoot.MRM NAME 'anything' TYPE MRM.Bitstream VALUE yourBLOB; |
|
Back to top |
|
 |
umaneesh |
Posted: Tue Oct 27, 2009 1:46 pm Post subject: Re: CSV with appended spaces |
|
|
Novice
Joined: 13 Apr 2009 Posts: 24
|
Hi,
I am facing the similar situation here. Need to have padding character as SPACES in CSV simple string elements. It is parsing fine but produces the same without padding.
something like this:
"aerodynamics,turbulence,6.1.0.4"
Should transform as
"aerodynamics ,turbulence ,6.1.0.4 "
I have to parse field by field, as the fixed length differs in each field.
Thanks. |
|
Back to top |
|
 |
kimbert |
Posted: Tue Oct 27, 2009 3:04 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Doesn't 'Observe element length' meet the requirement? |
|
Back to top |
|
 |
|