loading as per date value
Moderators: chulett, rschirm, roy
loading as per date value
hi all
i have got a flat file to load into a table along with date..the flat file has different segments where the date value and its corresponding set of records is given..then another date value and another set of records...how to read such a file..
i m giving the format of file below
generation date:11/11/2006
65896565,A123F,C112K
89645235,A123F,C112K
.
.
generation date:12/12/2006
65896565,A123F,C112K
89645235,A123F,C112K
.
.
.
i have got a flat file to load into a table along with date..the flat file has different segments where the date value and its corresponding set of records is given..then another date value and another set of records...how to read such a file..
i m giving the format of file below
generation date:11/11/2006
65896565,A123F,C112K
89645235,A123F,C112K
.
.
generation date:12/12/2006
65896565,A123F,C112K
89645235,A123F,C112K
.
.
.
-
- Premium Member
- Posts: 1255
- Joined: Wed Feb 02, 2005 11:54 am
- Location: United States of America
Re: loading as per date value
Welcome aboarddr46014 wrote:hi all
i have got a flat file to load into a table along with date..the flat file has different segments where the date value and its corresponding set of records is given..then another date value and another set of records...how to read such a file..
i m giving the format of file below
generation date:11/11/2006
65896565,A123F,C112K
89645235,A123F,C112K
.
.
generation date:12/12/2006
65896565,A123F,C112K
89645235,A123F,C112K
.
.
.
![Smile :)](./images/smilies/icon_smile.gif)
I appreciate the way you framed your question and also the neat & clean sample file.
It is pretty easy to read such a file. Use a sequential file stage, read the incoming record as one field. Make sure that you define the length of this field equal to the maximum length of your incoming record.
Later in your transformation. you can use the field function to retrieve relevant information based on your output requirements.
Whale.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
As mentioned by Whale, read it as single varchar field, parse it in a transformer. Check for "generation date:" and store the date into a stage variable, and populate this variable in 4th column until you get a records with "generation date:". The 5th can be populated with SYSDATE or Date() in datastage.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
You can do this by reading the entire record as one column and then split it inside the transformer as Whale suggested.
Define a stage variable
Now your columns will be
Now your first three columns will be null for the line 'Generation Date:...'
So you need to constraint it by putting a second transformer infront of this transformer and specify a constraint
I think that should work.
Define a stage variable
Code: Select all
GenDate | if in.Link Matches 'generation...' then Field(in.Link,":",2)
else GenDate
Code: Select all
Col1 | Field(in.Link,",",1)
Col2 | Field(in.Link,",",2)
Col3 | Field(in.Link,",",3)
Col4 | GenDate
Col5 | DSJobStartDate
So you need to constraint it by putting a second transformer infront of this transformer and specify a constraint
Code: Select all
IsNull(link.Col1) = 0
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
thaks all you people for your immediate response.i hav a small doubt that how can read the file when i encounter the second generation value...
if u people suggest me code of the field function it will be very helpful
this is a really awesome community....i got the solution within 30mins..
one again thanks to all u people
if u people suggest me code of the field function it will be very helpful
this is a really awesome community....i got the solution within 30mins..
one again thanks to all u people
Field is an inbuilt function in Datastage.dr46014 wrote:if u people suggest me code of the field function it will be very helpful
This forum has a nice search functionality too which you can use to get most of your solutions.
Narasimha Kade
Finding answers is simple, all you need to do is come up with the correct questions.
Finding answers is simple, all you need to do is come up with the correct questions.