Reading file names

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
h4harry1
Participant
Posts: 16
Joined: Sat Mar 19, 2011 8:01 am

Reading file names

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

No need for an intermediate file/table, simply use your command of choice in the Filter property of the stage.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
h4harry1
Participant
Posts: 16
Joined: Sat Mar 19, 2011 8:01 am

Datastage

Post 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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply