1 00:00:00,000 --> 00:00:05,002 (bright upbeat music) 2 00:00:05,002 --> 00:00:06,000 - [Instructor] All right, 3 00:00:06,000 --> 00:00:08,001 it's time for another programming challenge. 4 00:00:08,001 --> 00:00:10,005 For this challenge, we're going to use XlsxWriter 5 00:00:10,005 --> 00:00:12,007 to perform an operation similar 6 00:00:12,007 --> 00:00:15,006 to one we did earlier in the course. 7 00:00:15,006 --> 00:00:20,000 So, your program is going to take the Inventory.csv file, 8 00:00:20,000 --> 00:00:21,007 which you can see here, 9 00:00:21,007 --> 00:00:25,005 and we'll transform it into an Excel workbook. 10 00:00:25,005 --> 00:00:27,009 The workbook will have separate worksheets 11 00:00:27,009 --> 00:00:30,008 for each of the categories of the items in the file. 12 00:00:30,008 --> 00:00:33,000 So in other words, there'll be worksheets 13 00:00:33,000 --> 00:00:36,008 for fruits and vegetables and meats and so on. 14 00:00:36,008 --> 00:00:39,005 And all the items associated with that category 15 00:00:39,005 --> 00:00:41,008 will be in that worksheet. 16 00:00:41,008 --> 00:00:46,004 Each worksheet will also have a copy of the column headers. 17 00:00:46,004 --> 00:00:48,001 So, I'm going to run my finished code 18 00:00:48,001 --> 00:00:51,007 so you can see what the output should look like. 19 00:00:51,007 --> 00:00:56,000 So here in my finished file, 20 00:00:56,000 --> 00:00:58,009 I'm going to run my finished solution 21 00:00:58,009 --> 00:01:04,001 and we can see that Inventory.xlsx has been created. 22 00:01:04,001 --> 00:01:07,008 So, let's open that up. 23 00:01:07,008 --> 00:01:10,006 All right, and sure enough, we can see that when I open it, 24 00:01:10,006 --> 00:01:13,004 there are worksheets for each category, right? 25 00:01:13,004 --> 00:01:17,005 So we have fruits, vegetables, meats, breads, and dairy. 26 00:01:17,005 --> 00:01:21,007 Each one of the sheets has the headers 27 00:01:21,007 --> 00:01:24,008 and the zoom level is set to 200. 28 00:01:24,008 --> 00:01:25,007 And you can also see 29 00:01:25,007 --> 00:01:29,007 that all the columns autofit the content. 30 00:01:29,007 --> 00:01:31,005 Okay, so it's your turn. 31 00:01:31,005 --> 00:01:33,004 Take some time to try out this challenge 32 00:01:33,004 --> 00:01:36,001 and I'll be back to show you my solution. 33 00:01:36,001 --> 00:01:38,000 If you want a hint, then keep watching. 34 00:01:38,000 --> 00:01:41,003 Otherwise, just stop the video here and get started. 35 00:01:41,003 --> 00:01:44,000 All right, you sure you want the hint? 36 00:01:44,000 --> 00:01:47,001 Are you sure you want the hint? 37 00:01:47,001 --> 00:01:48,003 All right, here's the hint. 38 00:01:48,003 --> 00:01:51,006 So, take a look at the defaultdict class 39 00:01:51,006 --> 00:01:54,005 in the Standard Library Collections module. 40 00:01:54,005 --> 00:01:56,003 You can use this to create a dictionary 41 00:01:56,003 --> 00:02:00,001 that maps string keys to other values 42 00:02:00,001 --> 00:02:01,009 like lists, for example. 43 00:02:01,009 --> 00:02:03,002 So, that's your hint. 44 00:02:03,002 --> 00:02:04,003 Go ahead, get started 45 00:02:04,003 --> 00:02:07,000 and I'll be back in the next video with my solution.