<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>hi, it&#39;s mike</title>
    <link>https://mike.puddingtime.org/tags/excel/</link>
    <description>Recent content on hi, it&#39;s mike</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <managingEditor>mike@puddingtime.org (mike)</managingEditor>
    <webMaster>mike@puddingtime.org (mike)</webMaster>
    <copyright>© 2026, mike</copyright>
    <lastBuildDate>Sat, 21 Aug 2010 07:00:34 +0000</lastBuildDate>
    <atom:link href="https://mike.puddingtime.org/tags/excel/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Let&#39;s Hear It for Lossy</title>
      <link>https://mike.puddingtime.org/posts/2010-08-21-let-s-hear-it-for-lossy/</link>
      <pubDate>Sat, 21 Aug 2010 07:00:34 +0000</pubDate><author>mike@puddingtime.org (mike)</author>
      <guid>https://mike.puddingtime.org/posts/2010-08-21-let-s-hear-it-for-lossy/</guid>
      
      <description>So, I’ve got this Excel spreadsheet that represents a dump of over 2,000 articles from an old CMS. Using the same general workflow I used before, I’m importing the spreadsheet into a local MySQL database using the Ruby spreadsheet gem. The importer I wrote just reads line by line, creates a new …</description>
      <content:encoded><![CDATA[<p>So, I&rsquo;ve got this Excel spreadsheet that represents a dump of over 2,000 articles from an old CMS. Using the same <a href="http://bit.ly/aMX94S">general workflow I used before</a>, I&rsquo;m importing the spreadsheet into a local MySQL database using the Ruby spreadsheet gem. The importer I wrote just reads line by line, creates a new ActiveRecord object then saves it.</p>
<p>Two thousand lines of spreadsheet &ndash; two thousand lines that include news-length content in each of their lines &ndash; is enough to make Excel (on the Mac) fall to its knees whining. Worse, after a few changes and saves, the spreadsheet library couldn’t even read the content. I tried saving it between .xls and .xlsx a few times and the problem persisted. I thought about pasting just the data into a blank spreadsheet to see if that would shake whatever rot had settled into the spreadsheet&rsquo;s soul, but getting Excel to copy and paste from a spreadsheet that big just made it beachball and crash.</p>
<p>So it was in a state of agitation that I decided to try one last thing: I opened the spreadsheet in Numbers, re-saved it as an Excel file and tried reading that in to my importer script. It not only worked, but the execution time of the script itself went from somewhere around 10 seconds to about 1.5. It was so much faster I rechecked my script, thinking I&rsquo;d commented out the line that actually saved the record.</p>
<p>I have no idea what goes on inside an Excel file, but if I had to guess, &ldquo;a lot of crap&rdquo; would probably be a big part of it. Some of that crap is, no doubt, useful to someone somewhere who&rsquo;d just die if they couldn&rsquo;t have this or that feature that&rsquo;s enabled by this or that bit of crap. I&rsquo;d also bet that there are people who are bitterly disappointed that Excel spreadsheets they&rsquo;ve opened or saved in Numbers have quietly stripped out some essential bit of crap they <em>need</em> to do their work. As near as I can tell, Numbers stripped out a bit of crap that kept me from doing mine. It&rsquo;s almost like discovering that high-compression JPEGS make bad pictures look better.</p>
<p>#excel #numbers</p>
<p><em><a href="mailto:mike@puddingtime.org?subject=Re%3A%20Let%27s%20Hear%20It%20for%20Lossy">Drop a line about this</a>.</em></p>]]></content:encoded>
    </item>
    <item>
      <title>In Which Mike Internalizes the Whole Class Thing</title>
      <link>https://mike.puddingtime.org/posts/2009-02-03-in-which-mike-internalizes-the-whole-class-thing/</link>
      <pubDate>Tue, 03 Feb 2009 09:07:14 +0000</pubDate><author>mike@puddingtime.org (mike)</author>
      <guid>https://mike.puddingtime.org/posts/2009-02-03-in-which-mike-internalizes-the-whole-class-thing/</guid>
      
      <description>Last year I wrote a class in Ruby that I use to pull information from stories published on sites I manage. Initially I was just looking for a way to write reports on what I’d published over the past week (title and publication date), but it eventually grew into something that can provide more data: …</description>
      <content:encoded><![CDATA[<p>Last year I wrote a class in Ruby that I use to pull information from stories published on sites I manage. Initially I was just looking for a way to write reports on what I&rsquo;d published over the past week (title and publication date), but it eventually grew into something that can provide more data:</p>
<ul>
<li>publication date</li>
<li>author</li>
<li>content</li>
<li>teaser</li>
<li>headline</li>
</ul>
<p>And it can also take the article content and pass back reformatted versions I can use for some frequent tasks: updating a page with links to news stories, or reformatting a story from a company site I don&rsquo;t manage.  I can feed it this URL:</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">http://www\.internetnews\.com/infra/article\.php/3800236/</span></span></code></pre></div>
<p>and get back this:</p>
<p>[sourcecode language=&ldquo;html&rdquo;]</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">&lt;p&gt;&lt;a href=&#34;http://www\.internetnews\.com/infra/article\.php/3800236/Juniper\+Breaks\+into\+New\+Terabit\+Territory\.htm&#34;&gt;&lt;b&gt;Juniper Breaks into New Terabit Territory&lt;/b&gt;&lt;/a&gt;&lt;br&gt;Juniper Rolls New Center Stage Core Routing System \-new platform could scale to 25 Tbps for core routing\.  &amp;mdash; 02/02/09&lt;/p&gt;</span></span></code></pre></div>
<p>[/sourcecode]</p>
<p>I hooked the code up to a Web front-end/bookmarklet and I probably get back 15 minutes a day using that instead of doing everything by hand (loading a page, getting its source, reformatting to suit my site&rsquo;s style, changing links as needed, etc.)</p>
<p>With the ability to tap Google Analytics via Ruby, it opens up some new territory for my class, especially since there are some peculiarities with the way Analytics interacts with some of the articles I track.</p>
<p>First, the CMS does some odd things with the URL, depending on a number of factors.  New articles have URLs like the one above, old ones don&rsquo;t have the search engine friendly URLs.  Some pages that show up in Analytics reports are continuation pages, and they get their own URLs (something like the above, only with the numeric id after &ldquo;article.php&rdquo; wrapped in underscores and another identifier).  Making it even more difficult, if you visit a continuation page, the link back to the first page of the article is in yet another format from the link you&rsquo;d come in from on the front page.   Printer-friendly pages have a different URL structure, too.  From Analytics&rsquo; perspective, those are all different pages.</p>
<p>When I&rsquo;m reading Analytics reports I don&rsquo;t always get the best sense of a how a multi-page story did because it&rsquo;s not very easy to see the traffic a given article pulled down on all its possible pages: printer-friendly, continuation, front page as visited by someone following a link from a continuation page.</p>
<p>Mercifully, every single article has one thing in common: an i.d. number is always somewhere in the URL, and it&rsquo;s always in a predictable place. So my class returns the i.d. of the article along with all the other data, which makes it nice for gathering the actual traffic information on articles for every URL they can appear under.</p>
<p>Which brings us to today&rsquo;s thing, which is marrying my class (CDEV) to Analytics mining with rugalytics so I can calculate how well a story is doing in terms of the views it has garnered vs. what it cost.</p>
<p>I&rsquo;ve been doing something like this in the context of a Rails app for a few months, but there&rsquo;s a new requirement to provide a spreadsheet instead of the HTML table.  I wouldn&rsquo;t mind being able to help coworkers who have to file the same report for their sites, either.</p>
<p>One reason I like writing this stuff up:</p>
<p>Since I&rsquo;d already done a lot of this in Rails, I already had the simple loops in place to get pageview counts and all that.  I didn&rsquo;t want to make the spreadsheet-generating version dependent on ActiveRecord, though, so I found myself needing a new place to stow article objects.</p>
<p><a href="http://goesping.org">Ed</a> clued me to <a href="http://www.ruby-doc.org/stdlib/libdoc/ostruct/rdoc/index.html">ostruct</a>, which let me create the story objects I use in the report without the brain-fog hashes induce.  The script loops through each of the items in the report, adding the pageviews for each reported instance of the unique id to the related story object.</p>
<p>In the version below, I used my CDEV class to create new article objects, then created yet another object using ostruct, which was sort of goofy of me because I already <em>had</em> story objects, courtesy of CDEV.  The only thing they were missing was the author&rsquo;s base rate and the number of pageviews a story has.  So I extended my class by adding two lines:</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">attr\_accessor :pageviews</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">attr\_accessor :cost</span></span></code></pre></div>
<p>which let me cut out some clutter, drop the ostruct requirement, save a few bytes of RAM and internalize a bit more of the Ruby way.  If CDEV were not simple, or if it were something I didn&rsquo;t want to modify directly, I could  also create a subclass and add the needed attributes:</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">class Article&lt;CDEV</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code>```
</code></pre>
<p>attr_accessor :pageviews</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">    ```
</span></span><span class="line"><span class="cl">attr\_accessor :cost</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">end</span></span></code></pre></div>
<p>So anyhow, another triumph of Rubygems married to really basic logic, though unlike <a href="http://mph.puddingbowl.org/2009/02/tracking-specific-domains-in-google-analyticsgoogle-docs/">this morning&rsquo;s entry</a> I actually contributed 200+ lines of code you can&rsquo;t see through the CDEV class:</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">&lt;p&gt;</span></span></code></pre></div>
<p>[sourcecode language=&ldquo;ruby&rdquo;]</p>
<p>!/usr/bin/ruby</p>
<p>require &lsquo;rubygems&rsquo;</p>
<p>require &lsquo;spreadsheet&rsquo;</p>
<p>require &lsquo;rugalytics&rsquo;</p>
<p>require &lsquo;ostruct&rsquo;</p>
<p>require &lsquo;/Users/mph/lib/ruby/CDEV&rsquo;</p>
<p>google_account = &lsquo;GOOGLE ACCOUNT NAME&rsquo;</p>
<p>google_password = &lsquo;GOOGLE ACCOUNT PASSWORD&rsquo;</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">Set up the spreadsheet</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">book = Spreadsheet\.open &#39;LOCATION OF SPREADSHEET&#39;</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">log\_sheet = book\.worksheet 0</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">author\_sheet = book\.worksheet 1</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">report\_sheet = book\.worksheet 2</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">set up the Analytics pull</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">Rugalytics\.login google\_account, google\_password</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">analytics\_channel = &#39;YOUR ANALYTICS ACCOUNT&#39;</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">analytics\_site = &#39;YOUR ANALYTICS REPORT&#39;</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">profile = Rugalytics\.find\_profile\(analytics\_channel, analytics\_site\)</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">report = profile\.top\_content\_report :from =&gt; Date\.today \- 90\.days, :to =&gt; Date\.today, :rows =&gt; 500</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">articles = Hash\.new\(0\)</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">def article?\(url\)</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code>```
</code></pre>
<p>url.include?(&ldquo;article.php&rdquo;)</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<p>end</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<p>def extra_page?(url)</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">    ```
</span></span><span class="line"><span class="cl">url\.include?\(&#34;\_&#34;\)</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">end</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">def id\(url\)</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code>```
</code></pre>
<p>if extra_page?(url)</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">      ```
</span></span><span class="line"><span class="cl">url\.scan\(/article\\\.php\\/\\d\{1,\}\_\(\\d\{1,\}\)/\)\[0\]</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code>```
</code></pre>
<p>else</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">      ```
</span></span><span class="line"><span class="cl">url\.scan\(/article\\\.php\\/\(\\d\{3,\}\)/\)\[0\]</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code>```
</code></pre>
<p>end</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<p>end</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<p>read in the authors</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<p>authors = Hash.new</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<p>author_sheet.each do |row|</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">    ```
</span></span><span class="line"><span class="cl">if row\[0\] \!= nil</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code>  ```
</code></pre>
<p>author_name = row[0]</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">      ```
</span></span><span class="line"><span class="cl">author\_rate = row\[1\]</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code>  ```
</code></pre>
<p>authors[author_name] = author_rate</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">    ```
</span></span><span class="line"><span class="cl">end</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">end</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">log\_sheet\.each 1 do |row|</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code>```
</code></pre>
<p>if row[0] != nil</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">      ```
</span></span><span class="line"><span class="cl">puts row\[0\]</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code>  ```
</code></pre>
<p>url = row[0].to_s</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">      ```
</span></span><span class="line"><span class="cl">cdev = CDEV\.new\(url\)</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code> ```
</code></pre>
<p>no need for all this now:</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">      ```
</span></span><span class="line"><span class="cl">article = OpenStruct\.new</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code>  ```
</code></pre>
<p>article.id = id(url)</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">      ```
</span></span><span class="line"><span class="cl">article\.title = cdev\.title</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code>  ```
</code></pre>
<p>article.author = cdev.author</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">      ```
</span></span><span class="line"><span class="cl">article\.pubdate = cdev\.pubdate</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code>  ```
</code></pre>
<p>article.cost = authors[cdev.author].to_i</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">      ```
</span></span><span class="line"><span class="cl">article\.url = url</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code>  ```
</code></pre>
<p>article.pageviews = 0</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">      ```
</span></span><span class="line"><span class="cl">articles\[article\.id\] = article</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code>```
</code></pre>
<p>end</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<p>end</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<p>report.items.each do |i|</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">        ```
</span></span><span class="line"><span class="cl">url = i\.url\.to\_s</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code>    ```
</code></pre>
<p>if article?(url)</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl"> </span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">          ```
</span></span><span class="line"><span class="cl">cdevid = id\(url\)</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code>      ```
</code></pre>
<p>if articles.include?(cdevid)</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">            ```
</span></span><span class="line"><span class="cl">articles\[cdevid\]\.pageviews \+= i\.pageviews\.to\_i</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code>      ```
</code></pre>
<p>end</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">        ```
</span></span><span class="line"><span class="cl">end</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">end</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">i = 1</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">articles\.sort\{|a,b| a\[1\]\.pubdate &lt;=&gt; b\[1\]\.pubdate\}\.each \{ |k,v|</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code> ```
</code></pre>
<p>row = report_sheet.row(i)</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">     ```
</span></span><span class="line"><span class="cl">row\[0\] = v\.title\.to\_s</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code> ```
</code></pre>
<p>row[1] = v.pubdate.strftime(&quot;%m/%d/%y&quot;)</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">     ```
</span></span><span class="line"><span class="cl">row\[2\] = v\.author\.to\_s</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code> ```
</code></pre>
<p>row[3] = v.cost.to_i</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">     ```
</span></span><span class="line"><span class="cl">row\[4\] = v\.pageviews\.to\_i</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code> ```
</code></pre>
<p>row[5] = v.pageviews.to_f/v.cost.to_f</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">    ```
</span></span><span class="line"><span class="cl">i \+= 1</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">\}</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">book\.write &#39;LOCATION OF OUTPUT FILE&#39;</span></span></code></pre></div>
<p>[/sourcecode]</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">&lt;/p&gt;</span></span></code></pre></div>
<p>#analytics #excel #ruby</p>
<p><em><a href="mailto:mike@puddingtime.org?subject=Re%3A%20In%20Which%20Mike%20Internalizes%20the%20Whole%20Class%20Thing">Drop a line about this</a>.</em></p>]]></content:encoded>
    </item>
  </channel>
</rss>
