[resolved] tFileInputTextFlat component

One Star

[resolved] tFileInputTextFlat component

Hi,
I am using a custom Talend component "tFileInputTextFlat" that is useful in processing CSV files. The job works for all CSV files, except one case. If the CSV files has incorrect Headers, this component throws an exception, but locks the original CSV file, thereby not allowing me to copy it to a different location.
CSV File:
ID,FEEEELD
1,field1
Column/Name in Header in tFileInputTextFlat component:
ID, Field
I am fetching all the CSV files in a location using tFileList, then using the custom component. I have also included a tJavaFlex on this component so that I can catch the appropriate error and write it to the logs. But I am not able to close the original input CSV file. In case there is no error, I am writing it to a tFileOutputXML component, and file is being closed automatically.
I need to use this component, as it gives me a flexibility of specifying columns arranged in different order, or having extra headers.

Accepted Solutions
Seventeen Stars

Re: [resolved] tFileInputTextFlat component

Hi Rohit,
Generally I would always suggest using the connection OnSubjobError to have an trigger for the error handling.
And yes, there is a workaround for experienced developers like you.
The component object tFileInputTextFlat has the method close().
I remember you surrounding the code with a try catch. You could call this close method by your self.
But I suggest using my update (not public at the moment, only available for you at the moment). Because of I do not have Windows (yes I know I have to use it to complete the test cases... it is a todo) I cannot reproduce the file lock because Unix systems behaves different then Windows in this matter.
I will send you the release 2.1 which should solve your problem and provides a addition return parameter HEADER_CONFIG_ERROR with type of Boolean. You can use it to steer your job.

All Replies
Community Manager

Re: [resolved] tFileInputTextFlat component

Hi
This custom component is developed and shared by jlolling, I think he is the best person who can help you, I am notifying this post to jlolling.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Seventeen Stars

Re: [resolved] tFileInputTextFlat component

My component opens a try block before iterating through the data sets and close the file after finishing the subjob (even in case of errors) BUT I forgot to close the stream in case of Exceptions in the header check.
It turns out it would be useful to have an additional information (a return value as global var) to know there is something wrong with the file structure. This can be used in an if connection after OnSubjobError or OnComponentError.
I will update this component, thanks for your test case !
One Star

Re: [resolved] tFileInputTextFlat component

Thank you shong and Jan for the prompt replies. Appreciate it.
Jan, by the time you update the component, is there a workaround or a patch to this issue?
Seventeen Stars

Re: [resolved] tFileInputTextFlat component

Hi Rohit,
Generally I would always suggest using the connection OnSubjobError to have an trigger for the error handling.
And yes, there is a workaround for experienced developers like you.
The component object tFileInputTextFlat has the method close().
I remember you surrounding the code with a try catch. You could call this close method by your self.
But I suggest using my update (not public at the moment, only available for you at the moment). Because of I do not have Windows (yes I know I have to use it to complete the test cases... it is a todo) I cannot reproduce the file lock because Unix systems behaves different then Windows in this matter.
I will send you the release 2.1 which should solve your problem and provides a addition return parameter HEADER_CONFIG_ERROR with type of Boolean. You can use it to steer your job.
One Star

Re: [resolved] tFileInputTextFlat component

Thanks Jan,
I used your update, and it did work. The handles got closed eventually.
As you suggested earlier, I tried calling the close() method for the tFileInputTextFlat, but since it's been declared inside a try catch, I was unable to close the component in such a case of specific error being thrown because of incorrect headers (when it tried to reconfigure field description by header line)
I see that the component is being closed now in case such a kind of error is being thrown and a parameter HEADER_CONFIG_ERROR gets updated and the error is being handled gently.
Thank you very much again for this fix. I'll mark the topic as resolved.