Sort file and store attributes

I have a process to check a folder, which identifies when a file is received and can read from it. So far so good, but I have a couple of problems.

The files in particular are email converted into text. This emails contains information for the robot to start a process with some of the attributes in the email.

The problems I’m facing are the following

1- The files have a reference ID based on the date & time that has been created like YYMMDDHHMMSS. This allows to order the files. But how can Uipath order the files so that it pickups up the older? Basically I want to create a first in first out sequence, so that the older request is being processed.

2- I need to read some data from the file to do a few tasks. The contents of the file is something like this:
From: user@server.com
Sent: 25 March 2017 12:37
To: Rob1
Subject: Rob1
Task: Process1
Attrib1: FEB17
Attrib1: 200012

The information I need to capture is

  • The email, so that I can inform the user that the task is being processed. (I don’t see an activity in Uipath, is it possible to send emails?)
  • The Task to start the required process
  • The attributes that are required in the task

How can I capture the information from the text file and store in in attributes to process it?

I’m attaching the example text file and the xaml file as a reference.

I would really appreciate to get some help or advice

170325123641.zip (238 Bytes)
Main.xaml (16.9 KB)

Please try this:

folder_path = “D:\TestExcel”
dir_info = new DirectoryInfo(folder_path)

dir_info.GetFiles().OrderBy(Function(x) x.CreationTime)

*Note- if you wants to sort on the basis of latest to old by replacing “OrderBy” to" OrderByDescending".

I have attached 2 workflow named as follows:

  1. Sort_Dir_files_Creation_time.xaml //For to sort files on the basis of dates cretion from last to new
  2. textdatahandling.xaml // For to Handle your text file data.

Yes it is possible to send an email by using “Sent outlook mail” or “Send Smtp mail” or “Send exchange mail” activities.

You are not able to see those activities because you have not installed “UiPath.Mail.Activities” package.first install it then after restart check it.

and if you do not know how to install packages then please search previous post on forum :slight_smile:

For further assistance please review this attached workflow and let me know :slight_smile:

Sort_Files_and_attributes.zip (4.9 KB)

Regards…!!
Aksh

2 Likes

Thanks. Testing now your suggestions now

Aksh,

I’m a bit stuck on the text handling. I’m getting an error message on the assignation, where the File.ReadAllLines is assigned to the array string_data

It seems like it is not recognizing the ReadAllLines. Once I enter File., the list of possible options does not include .ReadAllLines

I’m adding the xaml file

Regards

FolderTest.xaml (37.8 KB)

Hey @selrac

It is working for me and you have not imported the “System.IO” assembly in your project.

Use This:

System.IO.File.ReadAllLines(“C:\Users\name\Documents\UiPath\FolderProcess\Sort_Files_and_attributes\Sort_Files_and_attributes\170325123641.txt”)

and let me know :slight_smile:

Regards…!!
Aksh

2 Likes

Yes, that worked!!!
Thanks

Hey Aksh, How can you sort an array of string? any specific VB function to do that?

Yes we can by using Lambda expression or linq with “Orderby()” function with append of “ToArray()” function.

For e.g. - arr_str.OrderBy(function(c) c).ToArray()

For your Reference, please see attached workflow and let me know :slight_smile:
array_sort.xaml (9.5 KB)

Regards…!!
Aksh

3 Likes

Thanks! It works like a charm :slight_smile:

Hi Aksh,

How can you sort these files as per date modified?

Hey @MGDEL

This link will help you on this:

Regards…!!
Aksh

2 Likes

How to append values to an array?