Update csv file with timestamp

Hi all,

Still part of my project, I have a CSV file that contains names and email addresses. After an email is sent, I want UiPath of place a timestamp across the first line to confirm delivery, then iterates until it completes the list.

I’m not sure if I just use append or add data row/column. Your suggestion/s is/are appreciated.

Hi there @rojem

Seems like an easy one.

When you are iterating through the data table itself you can use add column activity with either current data time (dateTime.Now or even Now should work) or with a custom date time that you require to add it against a particular row.

If the iteration is already done and you have a csv file and you want to add it, then you can read range and import data into data table add column follow the above steps and write range again.

Hope this helps :slight_smile: revert if you face any issues.

Hi,

To clarify my case, the program I have reads through the CSV, creates the report, then send it by email.

What I want to achieve is after sending the email, it gets the system time, then updates the csv file under “Time sent” column, and proceeds with the next entry, until it completes the entire list.

Hi @rojem ,

Here the Steps to follow.

  1. Read the CSV in a DataTable
  2. Take counter variable with default value =1 .
  3. Iterate the DataTable with for Each.
  4. Inside for Each , Increment the counter by 1.
    5.Create the report and send Email and get the Status :true or false
  5. Take a DateTimeVariable to get System time.
  6. Take Write Cell Activity .Assuming time Sent is in column “B” . Specify the range as “B”+Counter.tostring // This is to get the dynamic range .
  7. If status is true : write the current date in the Dynamic cell
    9.If False : Log it / Proceed to next record.

Below is a sample for reference.


Mukesh

1 Like

Hi Mukesh,

Thanks for the feedback. But it seems that the Write Cell activity only writes it to an excel file, not a csv.

Yes , You are correct.

How about directly updating the datatable

  1. For Each Row activity to loop through all rows in your Data Table
  2. Inside the loop, use this Assign activity
    `row.Item(“columnName”) = Datetime value

Or,

Saving the datatable as Excel and then proceeding ?

Hi rojem,

Adding to mukesh, there was no specific cells for CSV, as it is delimiter based, so you have to do any operation in Datatable and produce CSV / Excel file

Thanks