Reading file name having spaces

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
AmeyJoshi14
Participant
Posts: 334
Joined: Fri Dec 01, 2006 5:17 am
Location: Texas

Reading file name having spaces

Post by AmeyJoshi14 »

Hi,

We are facing problem while reading the file which are having name sperated with spaces.
eg:
abc file.csv
abc file1.csv

We have tried to use File pattern in sequential file,where in we can able to read the file but in the data we also want the file name column currently the value is coming as "/home/dsadm/*.csv"

Can anybody suggest us some method where in we can read the file along with the filename... :?
Thanks in Advance!!
http://findingjobsindatastage.blogspot.com/
Theory is when you know all and nothing works. Practice is when all works and nobody knows why. In this case we have put together theory and practice: nothing works. and nobody knows why! (Albert Einstein)
miwinter
Participant
Posts: 396
Joined: Thu Jun 22, 2006 7:00 am
Location: England, UK

Post by miwinter »

Try double-quoting the filename with spaces, as the operating system will read space seperated strings as more than one argument.

As for the filename - what are you wanting to do with this exactly? You can add an option the stage to include 'file name column' which will add the filename the data was sourced from.
Mark Winter
<i>Nothing appeases a troubled mind more than <b>good</b> music</i>
AmeyJoshi14
Participant
Posts: 334
Joined: Fri Dec 01, 2006 5:17 am
Location: Texas

Post by AmeyJoshi14 »

miwinter wrote:Try double-quoting the filename with spaces, as the operating system will read space seperated strings as more than one argument.
Thanks for reply!!
It really worked. :)

In the sequential file stage we ahve added the fileNameColumn inorder to know which records are coming from the respective files.The output of the sequential file is coming as :

Code: Select all

Col1,Col2,FileNameColumn
1,ABC,/home/dsadm/*.csv
2,DEF,/home/dsadm/*.csv
But actually our requirement is

Code: Select all

Col1,Col2,FileNameColumn
1,ABC,abc file.csv
2,DEF,abc file1.csv
Inshort we just want the file name(not the whole path)...Any help on this :(

Again thanks for the help!!
:lol:

Regards,
Amey
http://findingjobsindatastage.blogspot.com/
Theory is when you know all and nothing works. Practice is when all works and nobody knows why. In this case we have put together theory and practice: nothing works. and nobody knows why! (Albert Einstein)
laknar
Participant
Posts: 162
Joined: Thu Apr 26, 2007 5:59 am
Location: Chennai

Post by laknar »

From next stage extract the filename from the full path.

Code: Select all

Field(Filenamecolumn:'/','/',4)
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That plus this should help, and there's no need to concat that extra delimiter.

ps. The Field() usage could be made more generic to always return the last field regardless of the number of delimiters rather than hard-coding it like that. FYI.
-craig

"You can never have too many knives" -- Logan Nine Fingers
AmeyJoshi14
Participant
Posts: 334
Joined: Fri Dec 01, 2006 5:17 am
Location: Texas

Post by AmeyJoshi14 »

chulett wrote:That plus this should help, and there's no need to concat that extra delimiter.

ps. The Field() usage could be made more generic to always ...
Thanks all for the reply !!
Now the job is working fine :lol:

Again Thanks all for the support :wink:
http://findingjobsindatastage.blogspot.com/
Theory is when you know all and nothing works. Practice is when all works and nobody knows why. In this case we have put together theory and practice: nothing works. and nobody knows why! (Albert Einstein)
Post Reply