Political ad TV party: Obama loves '2 Broke Girls.' Romney? 'Andy Griffith.'

Mitt Romney may or may not secure the presidency of the United States, but he appears to be in an optimal position to win Mayberry.

"The Andy Griffith Show" is the second-most Republican-leaning program in the country, as measured by the partisanship of the political ads that run during its episodes. Only the Olympics saw a higher percentage of Republican ads, according to a Yahoo News analysis of the filings reported to the Federal Communications Commission by the TV stations in the top 50 media markets.

Since August, the FCC has required stations in the top 50 markets to report all the political ads they air, giving us some sense of when and where campaigns and outside spending groups are spending their cash.

I analyzed the raw text of 14,000 of these filings and extracted about 50,000 individual records of a campaign, super PAC or party committee purchasing advertising time on a specific show. In the following interactive, you can browse through any of the 86 shows that came up at least 25 times in the sample. Click the buttons to go up or down through the shows, or use the bottom button to choose a show at random.

"2 Broke Girls" swung the most heavily to the Democrats—surprising, perhaps, given that the title evokes Mitt Romney’s message that the economy is floundering under President Barack Obama’s stewardship. (It is not surprising if you consider the subject: single women.) "Judge Joe Brown" came in second.

Unfortunately, the light of 10,000 suns could not completely disinfect the reams of raw democracy on where and when these ads are running. The FCC does not require stations to file the information in a way that’s useful to people armed with computers. We’re left with about 30,000 PDF files, totaling nearly 150,000 pages—many of which were scanned sideways or upside down. Nearly half the files could not be read by an optical scanner or could not reliably be connected to the group that ran the ads.

This makes it difficult to know the raw volume of money and airtime. But even a sample of the data gives us a tremendous amount of information about which audiences the campaigns and their surrogates most want to reach.

Thanks to the saintly work of ProPublica, which uploaded all of these files to a site called Document Cloud, we have the raw text of the documents. I used a computer script to extract the names of television shows from that raw text (at least the computer-readable parts). As usual, the numbing methodology is included below.

Because of the intrinsic chaos, we should not think of this data as a scientific sample of all political TV ad purchases. The volume of purchases in the sample does generally match figures from the Federal Election Commission, however: The two camps are advertising roughly in the same amounts, but the Democrats spend more through the campaign while the Republicans rely more on outside groups. Officials at the FCC warn that there is some risk of double counting in these documents, given that stations interpret what they have to disclose differently.

Maybe in 2016 they could use computers.

I used a Predictable Information Elimination algorithm to extract the names of TV shows from the documents, the (messy) source code for which is available on my GitHub page. Thanks again to ProPublica and the Sunlight Foundation, who have done a lot of work to reliably connect each document to the campaign or group paying for the airtime. When the same show turned up multiple times in one document, it was counted multiple times, since this almost always represents two discrete ad runs.

Chris Wilson can be reached at cewilson@yahoo-inc.com