Update, January 2012: Everything…yes, everything, is superseded by my free online book, The Bastards Book of Ruby, which is a much more complete walkthrough of basic programming principles with far more practical and up-to-date examples and projects than what you’ll find here.
I’m only keeping this old walkthrough up as a historical reference. I’m sure the code is so ugly that I’m not going to even try re-reading it.
So check it out: The Bastards Book of Ruby
-Dan
—
Update, Dec. 30, 2010: I published a series of data collection and cleaning guides for ProPublica, to describe what I did for our Dollars for Docs project. There is a guide for Pfizer which supersedes the one I originally posted here.
So a little while ago, I set out to write some tutorials that would guide the non-coding-but-computer-savvy journalist through enough programming fundamentals so that he/she could write a web scraper to collect data from public websites. A “little while” turned out to be more than a month-and-a-half. I actually wrote most of it in a week and then forgot about. The timeliness of the fourth lesson, which shows how to help Pfizer in its mission to more transparent, compelled me to just publish them in incomplete form. There’s probably inconsistencies in the writing and some of the code examples, but the final code sections at the end of each tutorial do seem to execute as expected.
As the tutorials are aimed at people who aren’t experienced programming, the code is pretty verbose, pedantic, and in some cases, a little inefficient. It was my attempt to think how to make the code most readable, and I’m very welcome to editing changes.
DISCLAIMER: The code, data files, and results are meant for reference and example only. You use it at your own risk.
-
Tutorial 1: Go from knowing nothing to scraping Web pages. In an hour. Hopefully – A massive, sprawling tutorial that attempts to take you from learning what HTML is, to the definition of an “if
Tutorial 2: Scraping a County Jail Website to Find Out Who’s in Jail – This uses all the concepts from the first tutorial and applies them to something that a cops reporter might actually want to try out.
Tutorial 3: Who’s Been in Jail Before: Cross-checking the jail logs with the court system with Ruby’s Mechanize – This lesson introduces you to another Ruby library that allows you to automate the filling-out of forms so that you can access online databases, in this case, California criminal case histories to see if current inmates are repeat-alleged-offenders.
Tutorial 4: Improving Pfizer’s Dollars-to-Doctors Pay List – Last week, Pfizer released a list of nearly 5,000 doctors and medical institutions that it made $35 million in consulting and expense payments. Fun. Unfortunately, the list, as it initially existed online, is just about useless to anyone wanting to examine trends. This tutorial provides a script to make the list more interesting to journalists.
Pingback: Coding for Journalists 101: Go from knowing nothing to scraping Web pages. In an hour. Hopefully. | Danwin: Dan Nguyen, in short
Pingback: uberVU - social comments
Pingback: Coding for Journalists 102: Who’s in Jail Now: Collecting info from a county jail site | Danwin: Dan Nguyen, in short
Pingback: Coding for Journalists 104: Pfizer’s Doctor Payments; Making a Better List | Danwin: Dan Nguyen, in short
Pingback: Caribous ahead 6-3 after 2nd
Pingback: A sharp-edged sword : The Temple News - rewiews & features in sharpala.com
Pingback: Coding for Journalists 101 : A four-part series | Danwin: Dan … | Ruby WebDev Insider
Pingback: Dan Nguyen: Coding for journalists – four online tutorials | Journalism.co.uk Editors' Blog
Pingback: links for 2010-04-19 | Aram on Mason
Pingback: How To Build a Deck Part 5: Stairs & Railings – The Home Depot | Stairs Construction Assembly
Pingback: Curated links! : Innovation in College Media
Pingback: Recommended Links for April 28th | Alex Gamela - Digital Media & Journalism
Pingback: I came, I saw, I coded. » What’s so important about pro-jos, anyway?
Pingback: links for 2010-05-17 « Onlinejournalismtest's Blog
Pingback: MediaShift . Your Guide to Digital Training Programs for Mid-Career Journalists | PBS
Pingback: links for 2010-06-25 | Tachydidaxy
Pingback: An introduction to data scraping with Scraperwiki | Online Journalism Blog
Pingback: La programmation, l’avenir du journalisme ? – Media Trend
Pingback: Why you need to learn (at least a little) code, and how to get started : BusinessJournalism.org Reynolds Center for Business Journalism
Pingback: Innsamling av data: verktøy for skjermskraping « Grafa (norrøn; grave)
Pingback: Mapping Ratata: Who’s Hot? « dataist
Pingback: The Bastards Book: A Programming Tutorial for journalists, researchers, analysts, and anyone else who cares about data | Dan Nguyen pronounced fast is danwin
Pingback: A few reasons to learn the command line « Chris Essig's blog
Pingback: Code, Don’t Tell: Programming as an Essential Journalism Skill | Dan Nguyen pronounced fast is danwin
Pingback: Get started with screenscraping using Google Chrome’s Scraper extension « dataist