Read data from data input flow

Six Stars

Read data from data input flow

Hi,

 

I am writing a custom component and want to use some input data. I use tFileInputDelimited and connect it with tMap to my component.

I now want to read every line of input and log it to the console. (Later I want to convert it and use it within my component, that is why tLogRow is not the right solution).

How can I do that?

I tried 

IMetadataTable preMetadata = null;
if ((node.getIncomingConnections()!=null)&&(node.getIncomingConnections().size()>0))
preMetadata = node.getIncomingConnections().get(0).getMetadataTable();
String inRowName = node.getIncomingConnections().get(0).getName();
List<IMetadataColumn> columns = preMetadata.getListColumns();%>
for (int i = 0; i < columns.size(); i++){
IMetadataColumn column = columns.get(i);%>
System.out.println(String.valueOf(<%=inRowName%>.<%=column.getLabel() %>));
<%
}

but it keeps printing 'null'..

When I run the same job but with tLogRow at the end (tFileInputDelimited - tMap - tLogRow), it logs every value on the console so I assume there is now problem with loading the file.

 

Thanks for your help!

 

 

Moderator

Re: Read data from data input flow

Hello,

There is a component tfileinputfullrow in talend which can read a file row by row and send complete rows of data as defined in the schema to the next component via a Row link.

Have you tried to use this input component before your custom component to see if it works?

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Six Stars

Re: Read data from data input flow

Hi,

 

thanks for you reply.

I tried tFileInputFullRow. But then the column only has one element. When I want to print it, it still prints 'null'.

When I use tLogRow it works fine.

Do you have any idea what my component does wrong?

 

 

Moderator

Re: Read data from data input flow

Hi,

What does your custom component look like? Have you already shared your custom component on talend exchange portal?

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Six Stars

Re: Read data from data input flow

Hi,

 

I have not published the component as it doesn't work for the moment. In attachment you can find the .xml and begin files.

 

 

Highlighted
Six Stars

Re: Read data from data input flow

Hi,

 

Somehow now it works. I had a look at the tFileOutputPDF component and changed some lines. I don't know what the mistake was but ich works Smiley Happy

 

But I still have a question:

If I put all the code to the begin.javajet file again I just get 'null'.

Why do I have to read for input in the main file?

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch