# Rendering in csv file

**URL:** <https://www.ruby-forum.com/t/rendering-in-csv-file/189011>\
**Category:** Rails\
**Created:** [May 21, 2010, 11:30pm UTC](https://www.ruby-forum.com/t/rendering-in-csv-file/189011 "2010-05-21T23:30:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chewmanfoo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c37758/32.png) [@chewmanfoo](https://www.ruby-forum.com/u/chewmanfoo)\
**Post date:** [May 21, 2010, 11:30pm UTC](https://www.ruby-forum.com/t/rendering-in-csv-file/189011/1 "2010-05-21T23:30:36Z")

</div>

I have an index page showing a table of network hosts with IP  
addresses, roles, hostname etc. Is it trivial to render that page to  
the browser as a csv file instead of html and link to that rendering  
on the index page? How is that done? Is there a nice rails csv  
rendering for dummies page?

Thanks in advance,

---

<div class="post-metadata">

**Author:** ![chewmanfoo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c37758/32.png) [@chewmanfoo](https://www.ruby-forum.com/u/chewmanfoo)\
**Post date:** [May 22, 2010, 7:33pm UTC](https://www.ruby-forum.com/t/rendering-in-csv-file/189011/2 "2010-05-22T19:33:27Z")

</div>

There is a nice gem for generating CSV files called FasterCSV. I  
would start with that - it has decent instructions. If you need to  
generate a large (e.g. thousands of lines) CSV file you may need to  
move to more advanced tricks for generating the file but start with  
that gem and see if that gets you going.

–Michael

---

<div class="post-metadata">

**Author:** ![chewmanfoo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c37758/32.png) [@chewmanfoo](https://www.ruby-forum.com/u/chewmanfoo)\
**Post date:** [May 24, 2010, 3:16am UTC](https://www.ruby-forum.com/t/rendering-in-csv-file/189011/3 "2010-05-24T03:16:09Z")

</div>

chewmanfoo wrote:

> I have an index page showing a table of network hosts with IP  
> addresses, roles, hostname etc. Is it trivial to render that page to  
> the browser as a csv file instead of html and link to that rendering  
> on the index page?

Yes.

> How is that done?

The same way as you would for HTML – specify a template to render.  
Check out respond\_to for more.

> Is there a nice rails csv  
> rendering for dummies page?

You don’t need one.

> Thanks in advance,

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
