Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Component tFileDelete cannot delete file created by tFileOutputExcel

Hello,
I am trying to delete files created with the component tFileOutputExcel depending
on a condition (deleteIfEmpty), but they cannot be deleted.
To simplify this sample, I substituted the component deleteIfEmpty by the component
tFileDelete, and deactivated deleteIfEmpty (see image).
Looking at the flow, all created files (with tFileOutputExcel) should be deleted by the tFileDelete
component, but they are not being deleted. It looks like the output file is still opened and cannot
be deleted.
I tried to connect (with "OnOK") the component "set Vars" and "tFileInputExcel_1" and none of
them is working.
Any hints?
- the component deleteIfEmpty should delete the file depending on the number of written rows
(i.e. globalMap.get("tFileOutputExcel_1_NB_LINE"))
- the code responsible for the deletion returns always "file could not be deleted":
java.io.File df = new java.io.File((String)globalMap.get("currentOutputFileName"));
if (df.exists() && df.isFile()) {
if (df.delete()) {
System.out.println("file deleted");
} else {
System.out.println("file could not be deleted");
}
Thanks!
eripet
---
Using...
TOS Version: 2.2.2
Language: Java
Labels (3)
12 Replies
Anonymous
Not applicable
Author

Hello,
Replace your deleteIfEmpty component by a tJavaFlex.
Put your code in the end part and link it to your tFileOuputExcel with a RunIf.
RunIf condition can be something like globalMap.get("tFileOutputExcel_1_NB_LINE"))>0
Regards,
Anonymous
Not applicable
Author

Hello mhirt,
thanks for your reply, but I am afraid your solution does not work neither.
The output Excel file is at the moment the code is executed (in JavaFlex -> End code) still open. I tried to attach it to different components (set Vars, tFileOutputExcel -see picture above-), but it did not work....
It looks like there is a bug, and the component does not close the files as it should, not even at the end of the whole job...
If I link a tFileDelete component to the showInfo component the file will NOT be deleted. If I check the "fail on Error" box the code throws no exception, as the file is still there and delete() returns only true if the file exists and was deleted or false it it exists and was not deleted.
If thousands of files are to be created by such a job, I can imagine that it would get slower and slower and crash at some stage, as the needed OS ressources are limited!
Can you please take a closer look to this issue?
Thanks!
eripet
Anonymous
Not applicable
Author

You're right.
I tried and even if the file.close() command is sent at the end of the component tFileOutputExcel, before the call to the delete, the file.delete() command return false.
Same tJavaFlex in another independant job works.
Can you add a bugtracker entry for this problem ? I think it's related to the API used by the tFileOutputExcel.
Thanks for your support.
Anonymous
Not applicable
Author

Hello mhirt,
thanks for your reply.
New bug related to this issue opened: 2558
Thnx again!
eripet
Anonymous
Not applicable
Author

New bug related to this issue opened: 2558

This may not be a bug. Although you do say " the component does not close the files as it should, not even at the end of the whole job..." it does not seem to be the case in other contexts: as I describe it in https://community.talend.com/t5/Design-and-Development/create-an-excel-document-with-multiple-sheets... you can only touch the generated Excel file in a different subjob. Let me know.
Anonymous
Not applicable
Author

Hello,
I've somewhat the same issue, i'm triggering an error on my database connection and in that case i don't want any file generated. Yet talend still generates an empty file.
I cannot just check the "don't generate empty file' as some report can be empty.
I just want to have no report when there is a java error and i cannot find how to do it, because the file is opened until the end of the job and i cannot delete it or anything...
Anonymous
Not applicable
Author

Long Path Tool helped me in this situation. http://PathTooDeep.com
_AnonymousUser
Specialist III

Why not you are trying long path tool? Long Path Tool helped me in this situation. http://PathTooDeep.com
namaravaadi
Contributor

Hi,
I am using temp space as a my disk for lookup so it is creating so many oracle files in that space when job failed any reasong those files and folder I am trying to delete but it is not deleting folder.
I tried the below senarios.
onSubjobOk
tPostJob->tOracleClose>tFileExist->tFileDelete
this is using for only if job logging purpose--tLogCatcher>tsendMailonComponetOk->tFileDelete
tFileDelete<-onSubjobOk<tLogCatcher->tsendMail
Please let me know as soon as possibel.
Thanks
Narendharr