Code
From Reporting Cookbook: www.forjournalists.com/cookbook
Got a nifty piece of code that helps get a repetitive task done? Share it here.
The wiki software doesn't play well with programming code. Here is an explanation of how to format it so it looks nice.
Contents |
[edit] Perl Scripts
- NICAR Data Library downloader: A script that goes to NICAR's data library and downloads a user defined set of databases.
- Name parser: A simple example of using the Lingua::EN::NameParse module to parse a single name field into separate first, middle, last and suffix fields
- Processing fixed-width files: How to unpack a fixed-width file
- Soundex and Metaphone: Phonetic algorithms for matching databases
- Retrieving files by FTP: Simple script to automate retrieving files from ftp server using Net::FTP module
- Extract PDF pages: A simple utility to pull selected pages from a PDF
- WWW::Mechanize: An example of using Perl's Web automation module to delete spam from the Cookbook
[edit] Python Scripts
- College Football Penalty Finder: A script that goes to ESPN's play-by-play logs, finds and extracts information on penalties by a particular team.
- ZIP Code Finder: A script to use the Google geocoder to find ZIP codes for a file of addresses.
- Election Results Scraper: A script that goes to USA Today's election results pages and pulls out the county by county results for each state.
- Concatenate files: A script that takes a bunch of files of the same type (has to be txt or some kind of markup, like html, xml, etc.) and mushes them together into one big file. Good for quick db-building.
- Combine spreadsheets: A script to combine multiple Excel spreadsheets into a single delimited file.
- Itemizer: A script to create a two-column table of key-value pairs from datasets where rows contains a unique identifier and varying numbers of additional fields.
- Padding text files: A script that you can easily modify to pad fixed-width text files to make them easier to import into a database manager.
[edit] VBA Code
- VBA grouped medians: An Excel function that calculates medians from grouped frequency distributions.
[edit] Firefox
- How to make a search widget: A tutorial
[edit] SQL
- UDFs






