- [Cameron] Hi, I'm Cameron McKenzie.
I'm the Editor-In-Chief at theserverside.com.
You can follow me on Twitter @cameronmcnz,
and I wanna show you a simple example
of how to read, write, and even do some filtering
of some CSV files using UiPath.
So, to filter some CSV files, read some CSV, write some CSV,
the first thing you wanna do is create a new project,
and I'm gonna call this "ReadWriteCSV,"
maybe even copy that into the description as well.
So, that will create the basic project here.
And with the project created,
I'm gonna open the main window.
And I'm gonna look over here under app integration.
I've been playing around already,
so you can see it sort of in my Favorites and Recents,
but, if you don't have it there,
you go into app integration, you'll see "CSV,"
and you'll see "Read CSV" is one of your options.
Throw that down there.
Now it's gonna say, "What file do you want to read?"
and if you click this "Browse for file,"
you'll notice that, by default,
it sends you into the name of the project,
the root of the project.
And so I don't actually have any CSV files in there.
So I'm actually going to open up Windows Explorer
actually go into that project,
and I'm going to create a new file here
called "input file dot CSV."
(pop up window alert chimes)
That's it there.
I'm gonna open it up with edit pad,
and I'm going to just paste the names
of some of my very favorite
Toronto talk show personalities into this file.
And there's John Moore, Mike Stafford,
Mike Coren, John Oakley, Mike Wilner.
Yep, they don't have real creative names
for the radio hosts in Toronto here,
lots of Johns and lots of Mikes.
That's my input file,
and I want to actually filter this down
so that there's no more Mikes in there,
that there's only Johns.
And so that's my input file,
I'm gonna need an output file as well,
so I may as well create the output,
file dot CSV.
And there we go, (pop up window alert chimes)
we've got all the files that we need.
So, now if I go back into UiPath,
you notice that those files are available.
So I click on this option here,
which file do you want to read from,
I'll read from input file.
And then it says, "What do you want to output this to?"
Well, I want to output it to a data table,
but the data table hasn't been defined yet,
so you have to go into variables,
click this button here,
you create a variable, and I'll call this "output."
And, sorry, I'm actually going to call it "input."
And it's going to be of type data table,
so we'll browse for types.
And, wow, look at all of those different types.
And you notice that there's a system data table in here
that I'm going to use.
And, of course, we've got one variable called
input of type data table,
I'm going to actually have another one called output,
and that will be of type data table as well.
That just allows us to set things up a little bit for later.
And both these will have scope for the entire sequence
that I'm currently working on.
Okay, so that's how we read a data file.
Now, let's say I want to actually filter this.
So with this file, I want to filter out all of the Mikes
and be left with just the Johns.
And so the way I do that is
I go into programming, program with a data table,
and, in this case, I'm going to filter the data table.
So I move that as the next next step in the sequence,
click on filter data table,
and what do I want to do?
Well, I want to filter that "First Name" column,
and I want to filter out,
so that's remove,
I want to filter out anything
that is equal to the word "Mike."
And if I take a look at this,
you'll see there's the "First Name" column,
and then we've got a bunch of Mikes in there.
Now, the input is going to be the input table,
the output of this is going to be the output table,
and notice that those map to the different variables
that I recently created.
So, those are both visible over here
under variables, input and output,
both of type data table.
And so again, that filter wizard's going to take
that first name, look for anything
that's equal to Mike,
and remove it from the input data table,
and then it will send the results to the output data table.
Now, what do you want to do with that?
Well, in this case, I want to actually write some CSV.
So I'm gonna throw that down there,
write some CSV.
To what file?
I want to filter that to the output file dot CSV.
And what is the data table that I'm writing to?
It is the output file.
I click Ctrl+S, so I save this here.
I wanna output that into input there,
make sure I've got input set up up here.
So, we read the CSV, save it to input,
that goes into this filter data table,
the filter data table takes the input, creates some output,
and then finally, when we write to the CSV,
we write that output in the output dot CSV file.
And so, there we go!
That is our basic process.
I am going to click "Run" here,
and you'll notice that there's no change to the input file,
but if I go in and I open up the output file,
you'll notice that we've only got the Johns left.
So, all the Mikes have been removed.
And there you go.
That's how easy it is to read some CSV,
do some filtering, and write some CSV.