(upbeat music)
- [Instructor] All right, it is time to try
a programming challenge with what we've learned.
For this challenge, you are going to write a program
that reads the contents of the inventory.csv file,
and you're going to add another column
to the data programmatically.
So if we look at the CSV file,
there are two columns for prices, right?
One for wholesale and one for consumer price.
You're going to add a column named margin
that will contain the difference
between the consumer and wholesale prices.
This means that you'll add another header
and then write out the updated rows.
So I'm going to run my finished example
so you can see what the results should look like.
I'm going to right click
and run my example here in the terminal.
Alright, so when I run my code,
you can see that the output file is created here
and when we look at the content,
you can see that there's a new column called margin,
and there's a new column of values
that contain the difference
between the consumer price and the wholesale price.
So that's the challenge.
Go ahead, give it a try
and I'll explain my code and how I solved it.
If you want a hint, then keep watching for a little longer,
otherwise, stop the video here,
go ahead and get started with the challenge.
All right?
Okay, do you want the hint?
Are you sure you want the hint?
Last chance.
All right, here's the hint.
When you read a CSV file,
all of the values are going to be read as strings,
so you're going to have to find a way
to convert the consumer price and wholesale prices
from a string into a number, okay?
So that's the hint.
Go ahead, fire up Google search if you need to,
and good luck on the challenge.
I'll see you in the next video.