<?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>DEVPYTHON</title>
	<atom:link href="http://devpython.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://devpython.com</link>
	<description>Notes on Python development</description>
	<lastBuildDate>Fri, 26 Aug 2011 02:38:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Post files to S3 with Boto</title>
		<link>http://devpython.com/2011/08/26/post-files-to-s3-with-boto/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=post-files-to-s3-with-boto</link>
		<comments>http://devpython.com/2011/08/26/post-files-to-s3-with-boto/#comments</comments>
		<pubDate>Fri, 26 Aug 2011 02:38:06 +0000</pubDate>
		<dc:creator>jc</dc:creator>
				<category><![CDATA[AWS]]></category>
		<category><![CDATA[S3]]></category>

		<guid isPermaLink="false">http://devpython.com/?p=24</guid>
		<description><![CDATA[Part of my job lately has been generating periodic CSVs (maybe I&#8217;ll talk more about this in a later post). To share them with my co-workers I decided that the apt thing to do was to pop them on S3 where storage is cheap and secure. To do this I wrote the following: 1234567891011121314from boto.s3.connection [...]]]></description>
			<content:encoded><![CDATA[<p>Part of my job lately has been generating periodic CSVs (maybe I&#8217;ll talk more about this in a later post). To share them with my co-workers I decided that the apt thing to do was to pop them on S3 where storage is cheap and secure. To do this I wrote the following:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">from boto.s3.connection import S3Connection<br />
from boto.s3.key import Key<br />
<br />
#... bunch of other cool stuff<br />
<br />
conn = S3Connection('&lt;key&gt;', '&lt;secret&gt;')<br />
bucket = conn.get_bucket('your_bucket')<br />
<br />
k = Key(bucket)<br />
# what you want the file to be named on S3<br />
k.key = 'your_data.csv' <br />
# file to be uploaded<br />
csv_file = '&lt;path to your csv file&gt;/your_data.csv'<br />
k.set_contents_from_filename(csv_file)</div></td></tr></tbody></table></div>
<p>Replacing the tedious work with 5 lines of code. <img src='http://devpython.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://devpython.com/2011/08/26/post-files-to-s3-with-boto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert UTC date string to unix timestamp</title>
		<link>http://devpython.com/2011/08/11/convert-utc-date-string-to-unix-timestamp/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=convert-utc-date-string-to-unix-timestamp</link>
		<comments>http://devpython.com/2011/08/11/convert-utc-date-string-to-unix-timestamp/#comments</comments>
		<pubDate>Thu, 11 Aug 2011 17:38:19 +0000</pubDate>
		<dc:creator>jc</dc:creator>
				<category><![CDATA[dateutil]]></category>
		<category><![CDATA[unix timestamp]]></category>

		<guid isPermaLink="false">http://devpython.com/?p=17</guid>
		<description><![CDATA[So you want to convert a UTC date string to a unix timestamp ? e.g. &#8220;2011-08-08T12:10:20+0000&#8243; This particular UTC date string was from a Facebook /feed. 1234&#62;&#62;&#62; import dateutil.parser &#62;&#62;&#62; d = &#34;2011-08-08T12:10:20+0000&#34; &#62;&#62;&#62; dateutil.parser.parse&#40;d&#41;.strftime&#40;&#34;%s&#34;&#41; '1312823420' Enjoy! Update: If you&#8217;re having issues like the following: 1TypeError: iter&#40;&#41; returned non-iterator of type '_timelex' Then more than [...]]]></description>
			<content:encoded><![CDATA[<p>So you want to convert a UTC date string to a unix timestamp ? e.g. &#8220;2011-08-08T12:10:20+0000&#8243; This particular UTC date string was from a Facebook /feed.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&gt;&gt;&gt;</span> import dateutil.parser<br />
<span style="color: #000000; font-weight: bold;">&gt;&gt;&gt;</span> d = <span style="color: #ff0000;">&quot;2011-08-08T12:10:20+0000&quot;</span><br />
<span style="color: #000000; font-weight: bold;">&gt;&gt;&gt;</span> dateutil.parser.parse<span style="color: #7a0874; font-weight: bold;">&#40;</span>d<span style="color: #7a0874; font-weight: bold;">&#41;</span>.strftime<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;%s&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
<span style="color: #ff0000;">'1312823420'</span></div></td></tr></tbody></table></div>
<p>Enjoy!</p>
<p><strong>Update:</strong></p>
<p>If you&#8217;re having issues like the following:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">TypeError: iter<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> returned non-iterator of <span style="color: #7a0874; font-weight: bold;">type</span> <span style="color: #ff0000;">'_timelex'</span></div></td></tr></tbody></table></div>
<p>Then more than like you&#8217;re using Python 2.x and dateutil 2.0 (as <a href="https://bugs.launchpad.net/dateutil/+bug/746550"> listed here</a>) Just downgrade to the compatible Python 2.x version like so:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span>easy_install python-dateutil==<span style="color: #000000;">1.5</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://devpython.com/2011/08/11/convert-utc-date-string-to-unix-timestamp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How many times does an item occur in a collection?</title>
		<link>http://devpython.com/2011/08/07/how-many-times-does-an-item-occur-in-a-collection/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-many-times-does-an-item-occur-in-a-collection</link>
		<comments>http://devpython.com/2011/08/07/how-many-times-does-an-item-occur-in-a-collection/#comments</comments>
		<pubDate>Sun, 07 Aug 2011 17:24:48 +0000</pubDate>
		<dc:creator>jc</dc:creator>
				<category><![CDATA[collections]]></category>

		<guid isPermaLink="false">http://devpython.com/?p=8</guid>
		<description><![CDATA[So you want to count the frequency of an item in a collection? In Python 2.7 and 3.1 there&#8217;s a number of new high performance container datatypes, namely the Counter. Example 1234&#62;&#62;&#62; a = &#91;'a','a','a','b','b','c','c','c','c','c','c'&#93; &#62;&#62;&#62; from collections import Counter &#62;&#62;&#62; Counter&#40;a&#41; Counter&#40;&#123;'c': 6, 'a': 3, 'b': 2&#125;&#41; Pretty bad ass.]]></description>
			<content:encoded><![CDATA[<p>So you want to count the frequency of an item in a collection? In Python 2.7 and 3.1 there&#8217;s a number of new high performance container datatypes, namely the <a href="http://docs.python.org/library/collections.html#collections.Counter">Counter</a>.</p>
<p>Example</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&gt;&gt;&gt;</span> a = <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'a'</span>,<span style="color: #ff0000;">'a'</span>,<span style="color: #ff0000;">'a'</span>,<span style="color: #ff0000;">'b'</span>,<span style="color: #ff0000;">'b'</span>,<span style="color: #ff0000;">'c'</span>,<span style="color: #ff0000;">'c'</span>,<span style="color: #ff0000;">'c'</span>,<span style="color: #ff0000;">'c'</span>,<span style="color: #ff0000;">'c'</span>,<span style="color: #ff0000;">'c'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
<span style="color: #000000; font-weight: bold;">&gt;&gt;&gt;</span> from collections import Counter<br />
<span style="color: #000000; font-weight: bold;">&gt;&gt;&gt;</span> Counter<span style="color: #7a0874; font-weight: bold;">&#40;</span>a<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
Counter<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #ff0000;">'c'</span>: <span style="color: #000000;">6</span>, <span style="color: #ff0000;">'a'</span>: <span style="color: #000000;">3</span>, <span style="color: #ff0000;">'b'</span>: <span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></div></td></tr></tbody></table></div>
<p>Pretty bad ass.</p>
]]></content:encoded>
			<wfw:commentRss>http://devpython.com/2011/08/07/how-many-times-does-an-item-occur-in-a-collection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

