Dartmouth Room Search - Sprint
I realized two days ago that there wasn't at all a good way to find rooms that fit your desires for upperclassmen housing. I contacted the housing office, and inquired as to if they had access to data about all of the rooms. Unfortunately, all they had was access to the same outdated floor plans that anyone could access. Sighing, I started looking through all of the PDF's to see if there was an easy way to extract the data. The links to the PDF's are scattered across pages, with differing numbers depending on what floors there are. I noticed they have a similar address pattern:
http://www.dartmouth.edu/~orl/images/floor-plans-06/<first four characters of building name>-<floor number (0-4).pdf. I quickly got the building names by copying them all and running a quick strip, and then using the
requests python module to check if the pdf file existed and then downloading it. You can check out the very easy download script here, on my Github.
I then had to figure out the best way to arrange the information. I brainstormed a list of attributes about each of the rooms (that doubled as the SQL columns), and wrote them all down. The list I finally ended up with was:
- id - SQL identifier (useful for pointing to specific room)
- building - the name of the building
- floor - int 0 through 4, where 0 is ground floor
- number - the room number (103, 204A, etc.)
- squareFeet - the total number of square feet in the room
- numRooms - the total number of rooms (ignoring bathrooms)
- numPeople - number of people that the room is intended for
- price - the price of the room (this is unused because I found out they're all the same)
- bathrooms - this was the hardest, as many of the rooms had different situations (it ended up just being descriptive strings)
- gender - 0 for either, 1 for both, 2 for guys, 3 for girls
- subFree - 0 if not, 1 if yes
The next thing that I had to figure out was how to add all the information. I contemplated using Mechanical Turks on Amazon, but figured that I could knock it out by myself in three hours or so, and watch some Game of Thrones at the same time. I coded a dirty but effective PHP addition page that evolved over time as I made it more efficient. It kept the information of the building, floor, and auto-incremented the floor number so that I didn't have to keep it in. It also saved previous bathroom, gender, and subfree status. The most time was spent changing bathroom, as there weren't options for it, and typing in the square feet. The page I used looks like this: It didn't look good, but it didn't have to. Four episode of GoT and a quick dinner later, I was done. I was missing Ledyard, because the PDF's were cropped (and the housing office STILL hasn't gotten back to me), but all of the data was in. Now I needed a way to display it.
I immediately just tried to get it to display. Eventually, I ended up with something terrible, that I (un)fortunately didn't manage to get a picture of. It was time to move onto the main functionality: searching.