<?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>ferrouswheel &#187; s3</title>
	<atom:link href="http://ferrouswheel.me/tag/s3/feed/" rel="self" type="application/rss+xml" />
	<link>http://ferrouswheel.me</link>
	<description>watching the world turn.</description>
	<lastBuildDate>Thu, 09 Sep 2010 22:21:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Python to parse fields in Amazon S3 logs</title>
		<link>http://ferrouswheel.me/2010/01/python_tparse-fields-in-s3-logs/</link>
		<comments>http://ferrouswheel.me/2010/01/python_tparse-fields-in-s3-logs/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 22:23:19 +0000</pubDate>
		<dc:creator>Joel</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[s3]]></category>

		<guid isPermaLink="false">http://ferrouswheel.me/?p=450</guid>
		<description><![CDATA[The log format for Amazon S3 is slightly annoying. Not  [...]]]></description>
			<content:encoded><![CDATA[<p>The log format for Amazon S3 is slightly annoying. Not overwhelmingly so, but the date field has the field separator (a space) in the middle of it and it isn&#8217;t encapsulated by quote characters. Here&#8217;s some code to split the fields up, assuming you&#8217;ve downloaded the log file already (it&#8217;s easy enough to list all logs and retrieve them with boto):</p>
<div class="codecolorer-container python twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:470px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">csv</span><br />
r = <span style="color: #dc143c;">csv</span>.<span style="color: black;">reader</span><span style="color: black;">&#40;</span><span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'logfilename'</span><span style="color: black;">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; delimiter=<span style="color: #483d8b;">' '</span>,quotechar=<span style="color: #483d8b;">'&quot;'</span><span style="color: black;">&#41;</span><br />
log_entries = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> r:<br />
&nbsp; &nbsp; i<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span> = i<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span> + <span style="color: #483d8b;">&quot; &quot;</span> + i<span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span> <span style="color: #808080; font-style: italic;"># repair date field</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">del</span> i<span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; log_entries.<span style="color: black;">append</span><span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://ferrouswheel.me/2010/01/python_tparse-fields-in-s3-logs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
