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!!
Reading file name having spaces
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 334
- Joined: Fri Dec 01, 2006 5:17 am
- Location: Texas
Reading file name having spaces
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)
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)
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.
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>
<i>Nothing appeases a troubled mind more than <b>good</b> music</i>
-
- Participant
- Posts: 334
- Joined: Fri Dec 01, 2006 5:17 am
- Location: Texas
Thanks for reply!!miwinter wrote:Try double-quoting the filename with spaces, as the operating system will read space seperated strings as more than one argument.
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
Code: Select all
Col1,Col2,FileNameColumn
1,ABC,abc file.csv
2,DEF,abc file1.csv
Again thanks for the help!!
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)
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)
From next stage extract the filename from the full path.
Code: Select all
Field(Filenamecolumn:'/','/',4)
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.
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
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 334
- Joined: Fri Dec 01, 2006 5:17 am
- Location: Texas
Thanks all for the reply !!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 ...
Now the job is working fine
Again Thanks all for the support
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)
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)