1 00:00:00,000 --> 00:00:05,003 (upbeat music) 2 00:00:05,003 --> 00:00:06,007 - [Instructor] All right, it is time to try 3 00:00:06,007 --> 00:00:09,006 a programming challenge with what we've learned. 4 00:00:09,006 --> 00:00:12,000 For this challenge, you are going to write a program 5 00:00:12,000 --> 00:00:16,001 that reads the contents of the inventory.csv file, 6 00:00:16,001 --> 00:00:18,006 and you're going to add another column 7 00:00:18,006 --> 00:00:21,000 to the data programmatically. 8 00:00:21,000 --> 00:00:24,001 So if we look at the CSV file, 9 00:00:24,001 --> 00:00:26,003 there are two columns for prices, right? 10 00:00:26,003 --> 00:00:29,006 One for wholesale and one for consumer price. 11 00:00:29,006 --> 00:00:33,003 You're going to add a column named margin 12 00:00:33,003 --> 00:00:34,008 that will contain the difference 13 00:00:34,008 --> 00:00:38,006 between the consumer and wholesale prices. 14 00:00:38,006 --> 00:00:41,004 This means that you'll add another header 15 00:00:41,004 --> 00:00:44,002 and then write out the updated rows. 16 00:00:44,002 --> 00:00:46,008 So I'm going to run my finished example 17 00:00:46,008 --> 00:00:49,009 so you can see what the results should look like. 18 00:00:49,009 --> 00:00:50,007 I'm going to right click 19 00:00:50,007 --> 00:00:54,008 and run my example here in the terminal. 20 00:00:54,008 --> 00:00:56,007 Alright, so when I run my code, 21 00:00:56,007 --> 00:01:00,006 you can see that the output file is created here 22 00:01:00,006 --> 00:01:02,004 and when we look at the content, 23 00:01:02,004 --> 00:01:07,005 you can see that there's a new column called margin, 24 00:01:07,005 --> 00:01:12,000 and there's a new column of values 25 00:01:12,000 --> 00:01:13,009 that contain the difference 26 00:01:13,009 --> 00:01:18,002 between the consumer price and the wholesale price. 27 00:01:18,002 --> 00:01:20,000 So that's the challenge. 28 00:01:20,000 --> 00:01:21,008 Go ahead, give it a try 29 00:01:21,008 --> 00:01:25,000 and I'll explain my code and how I solved it. 30 00:01:25,000 --> 00:01:28,006 If you want a hint, then keep watching for a little longer, 31 00:01:28,006 --> 00:01:30,004 otherwise, stop the video here, 32 00:01:30,004 --> 00:01:31,009 go ahead and get started with the challenge. 33 00:01:31,009 --> 00:01:33,004 All right? 34 00:01:33,004 --> 00:01:35,004 Okay, do you want the hint? 35 00:01:35,004 --> 00:01:37,004 Are you sure you want the hint? 36 00:01:37,004 --> 00:01:39,001 Last chance. 37 00:01:39,001 --> 00:01:40,004 All right, here's the hint. 38 00:01:40,004 --> 00:01:43,001 When you read a CSV file, 39 00:01:43,001 --> 00:01:46,006 all of the values are going to be read as strings, 40 00:01:46,006 --> 00:01:49,001 so you're going to have to find a way 41 00:01:49,001 --> 00:01:53,009 to convert the consumer price and wholesale prices 42 00:01:53,009 --> 00:01:56,004 from a string into a number, okay? 43 00:01:56,004 --> 00:01:57,008 So that's the hint. 44 00:01:57,008 --> 00:02:00,006 Go ahead, fire up Google search if you need to, 45 00:02:00,006 --> 00:02:01,009 and good luck on the challenge. 46 00:02:01,009 --> 00:02:03,000 I'll see you in the next video.