(bright upbeat music)
- [Instructor] All right,
it's time for another programming challenge.
For this challenge, we're going to use XlsxWriter
to perform an operation similar
to one we did earlier in the course.
So, your program is going to take the Inventory.csv file,
which you can see here,
and we'll transform it into an Excel workbook.
The workbook will have separate worksheets
for each of the categories of the items in the file.
So in other words, there'll be worksheets
for fruits and vegetables and meats and so on.
And all the items associated with that category
will be in that worksheet.
Each worksheet will also have a copy of the column headers.
So, I'm going to run my finished code
so you can see what the output should look like.
So here in my finished file,
I'm going to run my finished solution
and we can see that Inventory.xlsx has been created.
So, let's open that up.
All right, and sure enough, we can see that when I open it,
there are worksheets for each category, right?
So we have fruits, vegetables, meats, breads, and dairy.
Each one of the sheets has the headers
and the zoom level is set to 200.
And you can also see
that all the columns autofit the content.
Okay, so it's your turn.
Take some time to try out this challenge
and I'll be back to show you my solution.
If you want a hint, then keep watching.
Otherwise, just stop the video here and get started.
All right, you sure you want the hint?
Are you sure you want the hint?
All right, here's the hint.
So, take a look at the defaultdict class
in the Standard Library Collections module.
You can use this to create a dictionary
that maps string keys to other values
like lists, for example.
So, that's your hint.
Go ahead, get started
and I'll be back in the next video with my solution.