Merging a table linked to a csv file that no more exists


I have to merge some data from a file that can be created or not in the directory. That means that if the file exists I have to use it in a merge transformation defined in another table. The problem is that if file doesn’t exists, the merge transformation goes in error and execution of the project halt with error.
Is there a way to condition the merge transformation only if the table exist? Probably the best way should be to condition the importation of the cv file, creating an empty table with last used structure (number and name of the column). Any other solution?
Many Thanks

In this case you can use conditionally derived tables (explaned here). With them you can arrange exactly the logic you’ve described – a file will be loaded and merged only if it exists, otherwise an empty structure will be created.

Below is an example of conditional file load and merging. It works as follows:

Check existence of “data.txt” using the “File list” transformation and a filter. If the file exists, the table “Check file” will have 1 row. If it doesn’t the table will be empty.

Two conditionally derived tables perform different actions depending on whether the table “Check file” is empty or not. One derived table loads a file (using a helper project). The other creates an empty structure.

Both logical branches are joined together and the result (either loaded file, or empty structure) is merged with some existing dataset (in this case a sequence 1, 2,3).

Here is the example: Conditional (2.4 KB)

In the table “Check file” I’ve left a “Filter” transformation in disabled state. You can enable/disable it and see how the conditionally derived tables work differently depending on whether “Check file” contains the file name or not.

Great solution! I tried to use conditional derived tables but without File List Transformation it didn’t work.

Thank you! Bye

You’re welcome!