<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ediaz &#124; iamedu &#187; Municipalities</title>
	<atom:link href="http://ediaz.me/tag/municipalities/feed/" rel="self" type="application/rss+xml" />
	<link>http://ediaz.me</link>
	<description>Technology, Music, Development, Science</description>
	<lastBuildDate>Thu, 03 Jun 2010 23:28:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mexican States and Municipalities in Python</title>
		<link>http://ediaz.me/2009/12/mexican-states-and-municipalities-in-python/</link>
		<comments>http://ediaz.me/2009/12/mexican-states-and-municipalities-in-python/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 12:00:35 +0000</pubDate>
		<dc:creator>iamedu</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Municipalities]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://ediaz.me/?p=47</guid>
		<description><![CDATA[First of all, I want to say I am using a creative commons image with this post, it is from Christian Frausto Bernal go check his pictures, they are pretty good.
Ok, so today I needed to get the mexican states and municipalities to use in some Plone dictionaries, so I got that from the SEPOMEX [...]]]></description>
			<content:encoded><![CDATA[<p>First of all, I want to say I am using a creative commons image with this post, it is from<a href="http://www.flickr.com/photos/cfrausto/"> Christian Frausto Bernal</a> go check his pictures, they are pretty good.</p>
<p>Ok, so today I needed to get the mexican states and municipalities to use in some Plone dictionaries, so I got that from the <a href="http://www.sepomex.gob.mx/">SEPOMEX</a> site.</p>
<p>I processed it a little and I got a very simple python file.</p>
<p>I has two dictionaries, the first one called states has a dictionary of normalized id&#8217;s and names, for example:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p47code4'); return false;">View Code</a> PYTHON</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p474"><td class="code" id="p47code4"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> states <span style="color: #ff7700;font-weight:bold;">import</span> states
<span style="color: #ff7700;font-weight:bold;">print</span> states<span style="color: black;">&#91;</span><span style="color: #483d8b;">'distrito_federal'</span><span style="color: black;">&#93;</span></pre></td></tr></table></div>

<p>and you&#8217;ll get something like:</p>
<p>Distrito Federal</p>
<p>The other dictionary is the one with the municipalities, you can use it like this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p47code5'); return false;">View Code</a> PYTHON</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p475"><td class="code" id="p47code5"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> states <span style="color: #ff7700;font-weight:bold;">import</span> data
<span style="color: #ff7700;font-weight:bold;">print</span> data<span style="color: black;">&#91;</span><span style="color: #483d8b;">'distrito_federal'</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'miguel_hidalgo'</span><span style="color: black;">&#93;</span></pre></td></tr></table></div>

<p>And you should get something like Miguel Hidalgo.</p>
<p>Of your you can traverse it with something like:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p47code6'); return false;">View Code</a> PYTHON</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p476"><td class="code" id="p47code6"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">for</span> m <span style="color: #ff7700;font-weight:bold;">in</span> data<span style="color: black;">&#91;</span><span style="color: #483d8b;">'distrito_federal'</span><span style="color: black;">&#93;</span>.<span style="color: black;">keys</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">print</span> m</pre></td></tr></table></div>

<p>That way you can get every municipality key.</p>
<p>And of course you know.. it&#8217;s python and it should be pretty simple to convert it to mysql, csv, or another format you might be using..</p>
<p>So have fun!</p>
<p>If you think that might be helpful you can download it here:</p>
<p><a href="http://ediaz.me/wp-content/uploads/2009/12/states.py_.bz2">Mexican States and Municipalities</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ediaz.me/2009/12/mexican-states-and-municipalities-in-python/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
