[resolved] How to read data from a text file?

One Star

[resolved] How to read data from a text file?

Hi
I have a need to read the data from a text file in Query part of a table Input component in order to include the value from text file in Query.
Can someone please help me on how to retreive the value from text file and use it in Where clause of Query part (Not tFilterRow)
Best regards,
Kalyan

Accepted Solutions
Four Stars

Re: [resolved] How to read data from a text file?

Hi kalyan,
I think this is a duplicate thread...
try following
"select col1, col2, col3dtCol fom tbName where col3dtCol > '" + valreadfromtxtfile+"'"

Vaibhav

All Replies

Re: [resolved] How to read data from a text file?

This is pretty easy to do with Talend. 

One approach is to read from your file one row at a time and issue a query using the data retrieved from the file. 

To do this, we read from the file with a input component and attach its row output to a "tFlowToIterate" component. This component will iterate over every row of its input, putting the values of each row in the global map for us to use later.

We then attach a database Input component with the "iterate" link from the tFlowToIterate. In the query, we use java concatenation to pushdown the value of the current iteration into the WHERE clause of the input component. 

One Star

Re: [resolved] How to read data from a text file?

I am trying to read a date field value and assign it in to where clause of query part of an input table component. I am getting an incorrect syntax error while doing this.
My query part looks something like this:
"select col1, col2, col3dtCol fom tbName where col3dtCol > " + valreadfromtxtfile
Moderator

Re: [resolved] How to read data from a text file?

Hi,
You can set a context value for your parameter(valreadfromtxtfile)
Please see a related forum:http://www.talendforge.org/forum/viewtopic.php?id=37155
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.
Four Stars

Re: [resolved] How to read data from a text file?

Hi kalyan,
I think this is a duplicate thread...
try following
"select col1, col2, col3dtCol fom tbName where col3dtCol > '" + valreadfromtxtfile+"'"

Vaibhav
One Star

Re: [resolved] How to read data from a text file?

Thanks Vaibhav.