Building a Voter File: Using the Example File
As of the end of our last post, we've obtained and loaded into SQL a recent voter file from Adams County. This week we're going to examine using the file in a very basic way.
A voter file on its own will not do you much good--it's just a list of people. However, since it's in a table, we are able to pull out only the parts we want. For example, select * from adams_111708 where p2008='D' will spit out only those voters who voted in the 2008 Democratic primary; if we keep on adding conditions, then we can select increasingly exclusive lists of voters, and even learn things from the data that any one column could not tell us. For example, select * from adams_111708 where (p2008='D' or p2006='D' or p2004='D') and p2004!='R' and p2006!='R' and p2008!='R' would serve as one good surrogate for likelihood of voting in a Democratic primary. But to really know what we're targeting, this information will have to work with some other sources of information--polling, past voting patterns, and, to a certain degree, political intution.
For example, imagine that we looked at the cross-tabs of a poll we comissioned and determined that we wanted to send mail to all the voters who had voted in a previous Democratic primary, lived in West Union (assume for the moment that our fictional candidate is the mayor and the town serves as his base), and is over 65 (he's active in the Gray Panthers). To simply select the list, choose select count(*) from adams_111708 where regcity='WEST UNION' and birthyear<'1943' and (p2008='D' or p2006='D' or p2004='D');. There are 417 voters who fit this description--a large number to hand enter, but a snap in SQL. For instance, using commands in the format select * into outfile '/home/www/myfile.txt' from <mytable>; we can export the list into a tab-delimited text file. This should enable us to open it using a spreadsheet program or word processer, and make use of their mail merge capabilities. Going from raw comma-delimited file from the Secretary of State into a handy list of targeted mailing addresses is a useful trick; but in order to really make use of the data, we're going to have to get it into a better format. That is a subject I'll be taking up next week, and in the weeks to come.














Recent comments
5 hours 13 min ago
5 hours 15 min ago
2 days 16 hours ago
3 days 4 hours ago
3 days 9 hours ago
2 days 12 hours ago
3 days 14 hours ago
3 days 15 hours ago
3 days 18 hours ago
3 days 18 hours ago