Home  ||  Blog  ||  Projects  ||  Google Hacks  ||  Artificial Life  ||  Search  ||  About

CIA Factbook Grep in Python

This project is just a quick python script that parses the CIA world factbook, searches for a specific property, like population, and prints this property for all countries in the database.

Type: grepCia.py capital and you'll get a list of countries and capitals. It works for almost all properties speficied in the CIA datase.

The program makes a good start for any CIA data harvesting hacks.

downloadable files

grepCia.pySource code for this project. Run the script and pass something like capital


comment_1
by Gideon
How does this work?

comment_2
by Demosthenese
it's MAGIC!!!!

seems to be no more really up to date :-)
by tk
have a look at
http://www.cia.gov/cia/publications/factbook/fields/2057.html

implementation from there would probably be much faster than now.

but anyway: nice hack!!

Its so much faster now.
by Thomas
Great idea tk,

I've had a go at implementing it from the page you suggest. Also I've removed any extraneous new lines and html in the output.

See http://www.viner.plus.com/grepCiaVer2.py.txt

But wouldn't it be cool if it could give say the top 10 countries by GDP or total land area?

PS love the site Douwe.


Post a comment
(c) Douwe Osinga 2001-2005, douwe.webfeedback@gmail.com Vertaling Nederlands Duits?