View previous topic :: View next topic
|
Author |
Message |
superman
New User
Joined: 28 Mar 2011 Posts: 12 Location: india
|
|
|
|
Hello team,
I have a CSV file in which certain fields are populated as SPACES.
The seperator here is ';'----> semicolon
Name;Age;Address
John;25;Chicago
Mike;27;Denver
Abby;18;Ohio
In this file I populate the field values using an external DB2 call.
However sometimes my datbase contains spaces for a lot of fields.
Hence, the resultant file looks like this:
Name;Age;Place;.........
John; ;Chicago;........
;27;Denver;.......
Abby;18; ;........
Is there any way to truncate the unnecessary spaces in betwen the seperator ';' and generate the file as follows:
Name;Age;Place;.........
John;;Chicago;........
;27;Denver;.......
Abby;18;;........
Kindly help. |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
DB2 cannot directly generate CSV files, so why don't you do it in the program that actually retrieves the data from DB2 and writes out the CSV file?
Or am I too stupid to understand such a trivial problem? |
|
Back to top |
|
|
superman
New User
Joined: 28 Mar 2011 Posts: 12 Location: india
|
|
|
|
Yes I am using a COBOL program for this.It fetches the values from DB2 table then writes it into a file. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
So, then, as Mr. Prins suggests you will want to modify that program, won't you? |
|
Back to top |
|
|
superman
New User
Joined: 28 Mar 2011 Posts: 12 Location: india
|
|
|
|
Yes I know I can modify the cobol program use INSPECT clause etc fro truncating the spaces etc. but can this be doen with SORT /utility? |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
Ah, so you deliberately misstated the requirement in your thread title. Do you have any notion of what utilities are available at your site? |
|
Back to top |
|
|
superman
New User
Joined: 28 Mar 2011 Posts: 12 Location: india
|
|
|
|
We tried using the following:
OPTION COPY
INREC OVERLAY=(1:1,4502,SQZ=(SHIFT=LEFT,MID=C' '),
1:1,4502,TRAN=LTOU)
However we don't want to loose the any spaces between the data(JOHN**MILLER must remain as it is and not become JOHN*MILLER) i.e we just need to truncate spaces between seperators(;) for our csv file. |
|
Back to top |
|
|
|