#100DaysOfCode in Python Transcripts
Chapter: Days 37-39: Using CSV data
Lecture: Demo: Getting started with CSV processing
0:00 Alright let's create our little application for our demo
0:03 that will let us work with the CSV data.
0:05 I'm over here in the actual GitHub repository
0:09 and we're going to create our application here.
0:12 Now I want to create a virtual environment in here
0:15 before we get started
0:16 and maybe I'll even name it venv
0:20 So, I'm going to go to that same folder in my terminal here
0:24 and I'm going to run the command
0:26 to create the virtual environment
0:27 before I open this in PyCharm.
0:30 If you were going to continue working in the terminal here
0:32 and you wanted to say, run Python commands
0:34 you would do this on Mac and that would activate it,
0:39 and if you were on Windows you would just
0:41 say venv\scripts\activate.bat like that.
0:46 Either way, I guess you would use backslashes wouldn't you?
0:48 But, until you get started here
0:50 I'm not going to worry about this because
0:51 I'm going to work in PyCharm and so
0:53 if I throw this over here or on Windows or Linux
0:56 say file, open directory it'll open this up
0:59 and I'll go ahead and let it add the GitHub root
1:02 doesn't matter so much for you guys
1:03 but I'm going to of course check all the stuff in.
1:06 Now, we can just go to our virtual environment
1:08 and say let's just ignore this,
1:10 it doesn't really matter
1:12 and we're just going to get started like we have been
1:14 by creating a program.py
1:17 this is going to be our little way to explore,
1:19 and this is going to be the top level thing
1:21 that we want to work with.
1:23 So, I'm just going to print out kind of the basic structure
1:27 of what we're going to do in terms of working with this data
1:30 and then we'll actually go write the code to implement that.
1:34 So, I'm going to define a main method here
1:37 and just for a minute I'm going to do the pass.
1:40 We'll do this little structure that is very common in Python
1:42 that says only directly execute this code
1:45 if it's being invoked directly,
1:48 if it's being used as a library.
1:50 Don't run main just leave the other functions here.
1:52 So this is the common pattern
1:53 and we're going to print out a few things.
1:55 We'll print out a little header value.
1:57 Alright, so weather research for Seattle 2014 to 2015
2:00 and we'll just put a blank line like that.
2:03 And then we're going to need to initialize the data.
2:12 Spelling is hard that's why PyCharm can fix it for us.
2:15 Okay, so that's going to be great
2:17 and once we get down here,
2:18 we want to answer the questions.
2:20 What, say, the hottest five days?
2:24 And then we'll say to do show the days.
2:28 And we're going to do this for a couple of different ways.
2:31 I'm going to come in here and I want to answer
2:32 the coldest five days and the wettest five days.
2:41 So, this is our goal is to run
2:43 basically answer these questions
2:45 and we're going to do that by reading that CSV file.
2:48 Before we do, let's just really quickly run
2:50 and make sure this works.
2:52 Hey, it tells us basically here are the days,
2:55 but doesn't yet show them to us.
2:57 So we're going to need to get the data.
2:59 Let me actually make a little folder to organize that here.
3:02 I'll call this data.
3:04 And into that data file, I'm going to drop
3:05 this thing we downloaded in the previous video.
3:08 Drop that there.
3:09 PyCharm will put it over in the right place
3:12 and we can look.
3:13 Does it look correct?
3:15 Apparently PyCharm can help out with CSV files.
3:18 I don't really care.
3:20 But I do care about what the header values are going to be.
3:22 We're going to work with that later.
3:24 So maybe go ahead and copy that preemptively.
3:27 Now, I think we're pretty much ready to write the code
3:31 that is going to read that file
3:34 and then provide the data
3:35 so we can answer these questions here.