Reading CSV file and Writing the filtered data into the CSV file


#1

I am trying to read the CSV file and storing the current day data into another CSV file, for this I have created a data table and after comparing the current day I am storing the matching row value into the data table which I insertingReadcsv.xaml (16.7 KB)
data.xlsx (8.0 KB)
using Get row but its not writing anything in the new CSV file which I created. Please check my workflow where I am going wrong.


#2

Hi Asmit,
Please find the improved code.
I have made few changes to the add row activity inputs.

Readcsv.xaml (16.8 KB)


#3

Thank u so much .


#4

Bro , now i want to give a dynamic path for reading the CSV file from the folder so can u suggest me a solution for this. Basically i want to download a csv file from the webpage and want to read that csv file for this i want to give dynamic path so that i do not have to change the path if i run the same workflow in other system.


#5

In that case you can

1.Use the below code to fetch the latest downloded file :

Assign latestFile = String.Join("", Directory.GetFiles(C:\Users\sharathr\Downloads,"*.pdf",SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1) )

2.Then pass the LatestFile variable to Read CSV Activity.


#6

But here u are giving a path (C:\Users\sharathr\Downloads), if I run the workflow using this path it will throw an exception. Suggest me a solution so that it can run on any system without changing anything.


#7

Since “Download Folder Path” is different for different systems, it can be stored in config file.

or

Use the below code to get the “Downloads Folder Path” : slight_smile:

Environment.GetEnvironmentVariable(“USERPROFILE”)+""+“Downloads”


#8

Sorry,I don’t understand.


#9

It will give the current downloaded file ???


#10

Nope , it will only give the latest modified file in that folder.

To make sure that it picks the latest downloaded file, we have to implement a logic.

i.e Before downloading ,check for the latest file in folder and after downloading check for the latest file
If they are equal assume the file is not yet downloaded
and
If they are not equal , then it means the file has been downloaded.
**Don’t forget to set the timeout limit in your logic.


#11

Is there not any way that it can directly take the current downloaded file like this -
Directory.GetFiles(“C:\Users\ashwi\Downloads”).OrderByDescending(Function(f) New FileInfo(f).CreationTimeUtc).First(), In this line the problem is it’s taking the path also


#12

Can u share the workflow for this if u have any.