Hi friends,
In my dispatcher bot, I am saving excel file with timestamp like- Logs_10_14_2024_13:33:03 PM.
Now I want to read this excel file in performer bot. Can someone tells me how can we read downloaded file with this timestamp?
Hi friends,
In my dispatcher bot, I am saving excel file with timestamp like- Logs_10_14_2024_13:33:03 PM.
Now I want to read this excel file in performer bot. Can someone tells me how can we read downloaded file with this timestamp?
Ideally it would be the latest saved file as well
Usw for each file in folder and then sort by created time
Cheers
If your file getting saved by dispatcher then you can add the file path directly to the queue item and access it from the performer.
Not using orchestrator. Using datatables only
If your Dispatcher and Performer going to be in same bot, use Global variable to store the file path. With this approach you don’t need to pass it through any arguments from workflow to workflow. It will be available in every workflow of your project.
I have 2 bots for dispatcher & performer.
Have to read excel in performer bot.
Are you using queues?
If so then the suggestion from @ashokkarale would be the way to go.
File System will not allow to use : in the file name.
So your file names not going to be - Logs_10_14_2024_13:33:03 PM. Choose another character to separate hh, mm, ss
Also 24 hours clock will not have AM/PM. Get the requirements correctly!
Here is simple logic to get latest file with timestamp in file name.
I have considered file name as below due to earlier highlighted flows.
Output:
LINQ:
latestFile = arrFiles.Select(Function(file) New With { .FileName = file, .FileDateTime = DateTime.ParseExact(System.Text.RegularExpressions.Regex.Match(Path.GetFileName(file), "\d{2}_\d{2}_\d{4}_\d{2}_\d{2}_\d{2} (AM|PM)").Value, "MM_dd_yyyy_hh_mm_ss tt", System.Globalization.CultureInfo.InvariantCulture)}).OrderByDescending(Function(x) x.FileDateTime).FirstOrDefault().FileName
Thanks,
Ashok
Thank you @ashokkarale.
I was running a code which give similar output like yours and its working now.
Directory.GetFiles( path,“*.xlsx”).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Tolist(0)
I will try your code also
You don’t need to sort it while getting all the files as you need to sort it by File name timestamp not with the Creation time.
Just use this in first assign activity.
arrfiles=System.IO.Directory.GetFiles(path,"*.xlsx")
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.