Page 1 of 1

Reading file names

Posted: Tue Jun 21, 2011 5:26 am
by h4harry1
Hi All,
I have a list of files in unix. All the file names are in the format "somedate+abc.txt". eg 12062011abc.txt, 13062011abc.txt, 14062011abc.txt and so on.
I want to design a datastage job which will read these file NAMES and put the names (NOT CONTENTS) in a oracle table OR a comma seprated file.

One logic comes to my mind is, using ls command of unix and writing the output in a text file, then reading that file using sequence file stage. But i doubt how to delimit the file name properly so that I can read it later on.

Any Help or other logic
Thanks in advance.

Posted: Tue Jun 21, 2011 7:04 am
by chulett
No need for an intermediate file/table, simply use your command of choice in the Filter property of the stage.

Posted: Tue Jun 21, 2011 4:15 pm
by ray.wurlod
... or even in the ls command itself. Let's imagine you're using an External Source stage. The command is something like

Code: Select all

cd $dirpath ; ls -1 [0-3][0-9][0-1][0-9][1-2][0-9][0-9][0-9][0-9]abc.txt

Datastage

Posted: Tue Jun 21, 2011 8:46 pm
by h4harry1
Thanks for your reply.
Let me clear my problem again.


Have some files like 01012011abc.txt, 02012011abc.txt, 03012011abc.txt, 04012011abc.txt and these files keep on increasing on daily bases. I Have a job which extracts the data from these files and put in a table.

Let say my first file have 5 records, and similarly other files have some records as well. Now I want to add a new column in my target tables which will represent against the record from which file it is coming.

Something like :-

Column 1 Column 2 Column 3 File Name
Abc 34 Ghk 01012011abc.txt
Gf 46 Rdty 01012011abc.txt
Gf 76 Jkl 01012011abc.txt
Gf 34 Dfgh 01012011abc.txt
Gf 57 Kj 01012011abc.txt
H 65 Ru 02012011abc.txt
Gf 56 Gfj 02012011abc.txt
Hg 43 Kj 02012011abc.txt
Gh 78 ter 02012011abc.txt

Posted: Tue Jun 21, 2011 9:12 pm
by ray.wurlod
This is an entirely new problem. We gave solutions for the question you originally asked.

The new problem is solved completely differently, most probably by having the Sequential File stage generate a file name column.