Python Jumpstart by Building 10 Apps Transcripts
Chapter: App 9: Real Estate Analysis App
Lecture: Sketching out the Real Estate Data Miner App

Login or purchase this course to watch this video and the rest of the course contents.
0:00 All right, let's write the first part of our real estate data mining application.
0:05 And we'll follow my standard convention of having a main method, at the top here, and then using the main live template in PyCharm,
0:14 just sort of use the proper import safe way of invoking it, now we are going to do a couple of things,
0:20 we are going to as always define a print_header() and we'll just print out some basic stuff as usual,
0:26 so here is a standard header which we'll call from up here, the next thing we need to do is get the data file,
0:33 so let's write a method not the actual data but just the file name for the data, so notice down here,
0:40 let's talk about where are we getting our data from, we have a data subfolder next to our program,
0:44 and we have the Sacramento real estate transactions for 2008, so this turns out to be all of the real estate transactions
0:51 that I could find for Sacramento in 2008. Personal individuals, no business stuff. So we want access to this file, now we want to use again our OS
1:02 so we'll import OS and a lot of times we've been saying .path, .join and we would give it something like '.' for the current directory
1:09 and then we would say data and then we would say the name of this, in PyChrm you can hit ctrl+t and it gives you a rename
1:15 which is probably the easiest way to just copy the name there, but this '.' assumes that we are always using the working directory
1:25 just above the data folder, we always want to look right next to this program for its data
1:29 no matter where it's running so let's get the base folder in different way. We'll say base_folders os.path.dirname() and remember,
1:39 there is an __file__, a __file__, implicit variable for every module that's going to say here is the full path,
1:47 so we get the base folder and then we can just put base folder here, right, so now it doesn't matter where we are running our code,
1:54 we'll always get back to this, and then we'll just return that, let's do a little format really quick, and let's get the file it's called filename
2:02 say get data file and then just let's print this out really quick. All right, that looks correct, I have it on my desktop
2:10 and then here is our 09 real estate data and so on. Perfect, so that should work for getting us the file
2:16 now the next thing to do instead of this is to actually load the data so I'll just say data like this and we'll come back to what that means,
2:24 I'll just say load file, so we are going to do this in a couple of ways, we'll start out with like really basic way
2:31 and then we'll come back and do a little bit more. Ok, so we got our data sketched out,
2:41 and the very last thing that we are going to do, after we loaded up, maybe we'll print it out for a minute but I guess we can go and write query data
2:48 and that will just spit out the report and so on so feed it data, like so, and that's the last method we'll write, and then, move on.
2:57 So there we have the basic structure for our app and I don't know if I have shown you this for a while in PyCharm
3:03 but over here you can actually see the structure and jump around if you like that's kind of handy,
3:08 even better when you have classes and hierarchies and these sorts of things,
3:11 so next we are going to work on load data and actually parsing our csv file.

Talk Python's Mastodon Michael Kennedy's Mastodon