1 00:00:08,000 --> 00:00:12,930 Welcome back. This lesson introduces the CSV format. 2 00:00:12,930 --> 00:00:18,195 CSV is an acronym that stands for Comma Separated Values, CSV. 3 00:00:18,195 --> 00:00:23,625 A file in CSV format is just a text file that follows certain conventions. 4 00:00:23,625 --> 00:00:27,840 The CSV format says that values are going to be separated by 5 00:00:27,840 --> 00:00:34,845 commas and it says that every line of the file will have the same structure. 6 00:00:34,845 --> 00:00:42,300 So, for example, we've got two commas on every line, 7 00:00:42,300 --> 00:00:46,185 One, two, one, two. 8 00:00:46,185 --> 00:00:50,015 So, we've got room for three things on each line; 9 00:00:50,015 --> 00:00:51,740 before the first comma, 10 00:00:51,740 --> 00:00:56,250 between the first and second and after the second one. 11 00:00:57,550 --> 00:01:07,665 Usually, you'll have the first line be special to give column names and then afterwards, 12 00:01:07,665 --> 00:01:10,520 all the rest of the lines are similar to each other. 13 00:01:10,520 --> 00:01:11,870 They each have values. 14 00:01:11,870 --> 00:01:15,290 The first value on line two is a name, 15 00:01:15,290 --> 00:01:19,945 the second value, 98 is a score, A+ plus is a grade. 16 00:01:19,945 --> 00:01:25,040 The reason this format is nice is that by having this standard format, 17 00:01:25,040 --> 00:01:28,720 you can have it read into lots of different programs. 18 00:01:28,720 --> 00:01:39,700 So, I've chosen to name this file grades dot CSV and it's saved on this computer. 19 00:01:42,260 --> 00:01:45,135 It's saved in this folder. 20 00:01:45,135 --> 00:01:49,765 On a Mac, when you have a file name that ends in dot CSV, 21 00:01:49,765 --> 00:01:52,855 unless you've configured your Mac some other way, 22 00:01:52,855 --> 00:01:54,575 when you try to open it, 23 00:01:54,575 --> 00:02:00,470 it defaults to thinking that you want to try to open it into an Excel spreadsheet. 24 00:02:01,140 --> 00:02:06,970 So here, it's taken that and instead of showing it to me as a text file, 25 00:02:06,970 --> 00:02:09,790 it's chopped it up and actually put 26 00:02:09,790 --> 00:02:14,815 the first values into column A and the second values in the column B, 27 00:02:14,815 --> 00:02:20,860 third values into column C. The same CSV format can be read not just by Excel, 28 00:02:20,860 --> 00:02:27,280 but by all kinds of statistics programs stayed are SPSS and so on. 29 00:02:27,280 --> 00:02:30,660 You can also open it in Google sheets. 30 00:02:30,660 --> 00:02:34,640 So, here's my Google Drive folder where I have some of 31 00:02:34,640 --> 00:02:38,030 my notes for these recordings and I've put that grades, 32 00:02:38,030 --> 00:02:41,465 that same grades dot csv file here, 33 00:02:41,465 --> 00:02:43,280 when I double-click on it, 34 00:02:43,280 --> 00:02:47,150 it gives me a little preview of what it would look like and it gives me 35 00:02:47,150 --> 00:02:52,085 an option to open it with Google sheets which is just another spreadsheet program. 36 00:02:52,085 --> 00:03:02,685 It's doing its little conversion and now we see it again in columns. 37 00:03:02,685 --> 00:03:06,425 So, the CSV format is kind of an interchange format. 38 00:03:06,425 --> 00:03:08,810 It's just a text file but if you follow 39 00:03:08,810 --> 00:03:11,945 the conventions and have the same number of commas on 40 00:03:11,945 --> 00:03:18,440 each line then it's going to be possible for a file to be read by any of these programs. 41 00:03:18,440 --> 00:03:20,255 At the end of this lesson, 42 00:03:20,255 --> 00:03:23,360 you'll be able to read a text file whose contents are in 43 00:03:23,360 --> 00:03:28,080 CSV format and pass the lines by using the dot split method. 44 00:03:28,080 --> 00:03:32,555 You'll be able to write a text file whose contents are in CSV format 45 00:03:32,555 --> 00:03:37,850 using either the dot format method with the string template or the dot join method. 46 00:03:37,850 --> 00:03:40,640 See you at the end of the lesson when I'll 47 00:03:40,640 --> 00:03:43,920 explain the difference between a cut and a comma.