RAVITEJA SATYAVADA
RAVITEJA SATYAVADA

Reputation: 2571

Creating File/output source in talend

I have a flow like

       tJava --> tFileOutputXML 

component in my job. When my condition met, i need to close that xml and have to create a new xml source. Is this possible in talend ??

I will try to explain my question with an example. In my data, i have 10 records of which 8 records were about user1 and 2records were about user2. So, now 8 records has to place in user1.xml and 2 records in user2.xml. Here, Number of records and number of users in data may increase time by time. I need to create those many files with associated user data..

Upvotes: 0

Views: 3110

Answers (1)

Shanmuga Priya
Shanmuga Priya

Reputation: 56

If your source data is in file:

  1. Using tAggregateRow component, fetch the distinct usernames.
  2. Iterate on each of the username using tFlowToIterate component:
  3. Use Iterate link to connect to tJava component.
  4. Assign the username to context variable using tjava component. For eg. if output row from the aggregate component is row1, then context.username=row1.username.
  5. Connect tJava to a file component using 'OnComponentOk' to read the data in file.
  6. Filter the records using tmap or tFilterRow for the value of username ie., context.username
  7. Write data into file. Give filename as "\"+context.username.

If your source data is in table:

  1. Select distinct username from table.
  2. Use tFlowToIterate to iterate on each of the usernames. (connect table component to this component using main link)
  3. Use Iterate link to connect to tJava component.
  4. Assign the username to context variable using tjava component. For eg. if output row from the table component is row1, then context.username=row1.username.
  5. Connect tJava to a table component using 'OnComponentOk' to Select data from table based on the where condition: username='"+context variable+"'
  6. Write data into file. Give filename as "\"+context.username.

Upvotes: 1

Related Questions