<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Slurping up and Spitting out CSV Files in Ruby with FasterCSV and Ruport</title>
	<atom:link href="http://unixmonkey.net/?feed=rss2&#038;p=23" rel="self" type="application/rss+xml" />
	<link>http://unixmonkey.net/?p=23</link>
	<description>creative engineering and technological abuse</description>
	<lastBuildDate>Thu, 05 Aug 2010 19:47:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Nikhil</title>
		<link>http://unixmonkey.net/?p=23&#038;cpage=1#comment-26199</link>
		<dc:creator>Nikhil</dc:creator>
		<pubDate>Sat, 12 Jun 2010 07:41:12 +0000</pubDate>
		<guid isPermaLink="false">http://unixmonkey.net/?p=23#comment-26199</guid>
		<description>Very enlightening post !! 
Thanks :)</description>
		<content:encoded><![CDATA[<p>Very enlightening post !!<br />
Thanks <img src='http://unixmonkey.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel Chippindale</title>
		<link>http://unixmonkey.net/?p=23&#038;cpage=1#comment-6396</link>
		<dc:creator>Joel Chippindale</dc:creator>
		<pubDate>Tue, 05 Aug 2008 05:44:06 +0000</pubDate>
		<guid isPermaLink="false">http://unixmonkey.net/?p=23#comment-6396</guid>
		<description>Thanks Dave.

If you want to customise exports beyond just selecting which columns are output then &lt;a href=&quot;http://github.com/econsultancy/csv_builder/tree/master&quot; rel=&quot;nofollow&quot;&gt;CSV Builder plugin&lt;/a&gt; allows you build templates with fastercsv.</description>
		<content:encoded><![CDATA[<p>Thanks Dave.</p>
<p>If you want to customise exports beyond just selecting which columns are output then <a href="http://github.com/econsultancy/csv_builder/tree/master" rel="nofollow">CSV Builder plugin</a> allows you build templates with fastercsv.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Unixmonkey</title>
		<link>http://unixmonkey.net/?p=23&#038;cpage=1#comment-6266</link>
		<dc:creator>Unixmonkey</dc:creator>
		<pubDate>Fri, 01 Aug 2008 18:25:48 +0000</pubDate>
		<guid isPermaLink="false">http://unixmonkey.net/?p=23#comment-6266</guid>
		<description>Thanks Greg, I wasn&#039;t aware Ruport did xls files directly... I&#039;ll definitely have to look at that for exporting for customers, but I do like CSV for internal import/export.

The Table() method could have saved me a ton of work a few days ago If I&#039;d only known about it. Definitely better than shifting ordinally.</description>
		<content:encoded><![CDATA[<p>Thanks Greg, I wasn&#8217;t aware Ruport did xls files directly&#8230; I&#8217;ll definitely have to look at that for exporting for customers, but I do like CSV for internal import/export.</p>
<p>The Table() method could have saved me a ton of work a few days ago If I&#8217;d only known about it. Definitely better than shifting ordinally.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gregory Brown</title>
		<link>http://unixmonkey.net/?p=23&#038;cpage=1#comment-6245</link>
		<dc:creator>Gregory Brown</dc:creator>
		<pubDate>Thu, 31 Jul 2008 20:33:09 +0000</pubDate>
		<guid isPermaLink="false">http://unixmonkey.net/?p=23#comment-6245</guid>
		<description>Oh, also... by installing ruport-util, Ruport can read/write xls, though I agree, CSV is usually better!</description>
		<content:encoded><![CDATA[<p>Oh, also&#8230; by installing ruport-util, Ruport can read/write xls, though I agree, CSV is usually better!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gregory Brown</title>
		<link>http://unixmonkey.net/?p=23&#038;cpage=1#comment-6244</link>
		<dc:creator>Gregory Brown</dc:creator>
		<pubDate>Thu, 31 Jul 2008 20:31:58 +0000</pubDate>
		<guid isPermaLink="false">http://unixmonkey.net/?p=23#comment-6244</guid>
		<description>Hi, thanks for writing this up about Ruport

If you put the names of the headers in the first line of your csv file, like:

name,address,email
...

You can just just Ruport (which uses FasterCSV under the hood):

&lt;pre lang=&quot;ruby&quot;&gt;
Table(&quot;my.csv&quot;, :records =&gt; true) { &#124;t,r&#124; User.create(r.to_hash) }
&lt;/pre&gt;

Of course, using FasterCSV is fine too, and probably a little more efficient.

With acts_as_reportable, you can use any of your find options, so you can write:

&lt;pre lang=&quot;ruby&quot;&gt;
content = User.report_table_by_sql(&quot;SELECT name, address, email FROM users&quot;).as(:csv)
&lt;/pre&gt;
as:
&lt;pre lang=&quot;ruby&quot;&gt;
content = User.report_table(:all, :only =&gt; [:name, :address, :email]).as(:csv)
&lt;/pre&gt;

Also, you can get rid of the file code:

&lt;pre lang=&quot;ruby&quot;&gt;
table = User.report_table(:all, :only =&gt; [:name, :address, :email])
table.save_as(&quot;#{RAILS_ROOT}/report.csv&quot;)
&lt;/pre&gt;

Those are just a few tips, nice article :)

-greg</description>
		<content:encoded><![CDATA[<p>Hi, thanks for writing this up about Ruport</p>
<p>If you put the names of the headers in the first line of your csv file, like:</p>
<p>name,address,email<br />
&#8230;</p>
<p>You can just just Ruport (which uses FasterCSV under the hood):</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">Table<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;my.csv&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:records</span> =&amp;gt; <span style="color:#0000FF; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> |t,r| User.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span>r.<span style="color:#9900CC;">to_hash</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p>Of course, using FasterCSV is fine too, and probably a little more efficient.</p>
<p>With acts_as_reportable, you can use any of your find options, so you can write:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">content = User.<span style="color:#9900CC;">report_table_by_sql</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;SELECT name, address, email FROM users&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">as</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:csv</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>as:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">content = User.<span style="color:#9900CC;">report_table</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:all</span>, <span style="color:#ff3333; font-weight:bold;">:only</span> =&amp;gt; <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:name</span>, <span style="color:#ff3333; font-weight:bold;">:address</span>, <span style="color:#ff3333; font-weight:bold;">:email</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">as</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:csv</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Also, you can get rid of the file code:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">table = User.<span style="color:#9900CC;">report_table</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:all</span>, <span style="color:#ff3333; font-weight:bold;">:only</span> =&amp;gt; <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:name</span>, <span style="color:#ff3333; font-weight:bold;">:address</span>, <span style="color:#ff3333; font-weight:bold;">:email</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
table.<span style="color:#9900CC;">save_as</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;#{RAILS_ROOT}/report.csv&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Those are just a few tips, nice article <img src='http://unixmonkey.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>-greg</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Baldwin</title>
		<link>http://unixmonkey.net/?p=23&#038;cpage=1#comment-5693</link>
		<dc:creator>David Baldwin</dc:creator>
		<pubDate>Thu, 17 Jul 2008 22:59:12 +0000</pubDate>
		<guid isPermaLink="false">http://unixmonkey.net/?p=23#comment-5693</guid>
		<description>Great article Dave.  I just recently started looking into Ruport and am very impressed with it&#039;s power and flexibility.</description>
		<content:encoded><![CDATA[<p>Great article Dave.  I just recently started looking into Ruport and am very impressed with it&#8217;s power and flexibility.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
