Hi,
I need to take and use files that start with a specific string.
Every day I will have a file in an SFTP folder, like this:
DailyExport_10_01_2020_MYtest_01-Oct-2020 06-42_2a612473-8c0b-4c9a-a221-6352090523fb.csv
where first part of the name is almost fix but the second not and not predictables.
With “File transfer” action I can take the files simply using this parameter:
{Folder path}&“DailyExport_”&format(today(),‘MM_dd_yyyy’)&"_MYtest*"
The * at the end works.
But after file import I can’t do the same in other actions, for example “Import delimited text file” or “File command”, because the * doesn’t work.
after downloading the file into designated folder, use the “List of files” action to capture the file name in that folder. You may need to apply additional filters to keep only the 1 correct file on the list.
After that, use the “Iterate” action to do a one-time iteration of a module with the file path assigned via a parameter. Thus, inside that module, you will have the exact file name as a parameter that you can use in any necessary action.
Thank you Dmitry!
I was just writing that I did so.
Anyway I also found some interesting calculated parameter that help me, like this:
keepbefore({FileNameOriginal},’_MYtest’)&".csv".
I need to import two different files (that change their names every day) into two tables that I have to merge in the next module.
How can I set the right sequence?
The 1st error says that file not found. The file path in the error message is incorrect (a file path can’t end with a slash). It seems like a file name is missing in the path. How is that file path calculated? Clearly, it’s not correct.
I think the error says that it can’t find the file, because file name is missing, but file name should be the parameter sent by Iterate.
With only one iteration it worked, I think it is something related to the fact that now I have two iterations working in parallel.
The iteration mechanism in EasyMorph works with multiple iterations of the same module in parallel independently. Every iteration works with an invisible clone of a module and its parameters. One iteration can’t affect a module (or its parameter) used in another iteration in any way, all iterations are completely isolated from each other.
However, if two iteration loops deal with the same file, then you may need to make sure that the file doesn’t get deleted or modified in one loop while another loop also accesses the file.
I see that in the “Iterate” action you assign the parameter value with a file name only. It means that the full path is calculated in the module, probably using a calculated parameter. It seems like that calculation works incorrectly, because the resulting path (visible in the error message) is not correct.
I checked the path calculation and it seems correct, anyway to avoid problems I changed with File name with full path.
But I think there is something not clear to me on iteration and parameter: I create the parameters and left them blank, because they have to take value from iterations
But what does it means this? Tomorrow when the file will change, will the procedure work well with new file names in parameters or will it work with old file names that I fixed today?
Thank you and sorry but I’m going crazy with these iterations and parameters…
The problem is that the called module has 2 parameters:
But only 1 parameters gets assigned in each iteration. One iteration assigns parameter FileNameQ0def which means that the other parameter (FileNameOriginal) remains unassigned and therefore empty.
The other iteration, vice versa – assigns parameter FileNameOriginal which means that the other parameter (FileNameQ0def) remains unassigned and therefore empty.
So in each iteration at least 1 parameter remains unassigned and therefore keeps the default empty value, which causes the errors.
The iterated module has 2 import actions that require 2 parameters with file paths. If at least one of them is empty, the module will fail. In order to make it work, in both iterations all 2 parameters should be not empty. I suppose both of them should be assigned in the “Iterate” action, for clarity.