Page 1 of 1

Reading file name having spaces

Posted: Tue Sep 01, 2009 3:36 am
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!!

Posted: Tue Sep 01, 2009 3:43 am
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.

Posted: Tue Sep 01, 2009 11:43 pm
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

Posted: Tue Sep 01, 2009 11:52 pm
by laknar
From next stage extract the filename from the full path.

Code: Select all

Field(Filenamecolumn:'/','/',4)

Posted: Wed Sep 02, 2009 12:02 am
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.

Posted: Wed Sep 02, 2009 3:51 am
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: