Convert data as CSV problem

hi all,

I want to convert my data as CSV file. just i used simple coding, i
didn’t use fastercsv, because i installed in my system, but i couldn’t
see where it install, if i run also , it said there is no fastercsv
file. actaully i don’t know how to use that.

so now i used simple code is, but in this csv file is downloaded , by
its coming with all HTML tags, even i didn’t use any html tags. so i
want to know how to avoid this. please any one help me. thanks in
advance.

in controller:

def report
@partner=Code.find(:all)
response.headers[‘Content-Type’] = ‘text/csv; charset=iso-8859-1;
header=present’
response.headers[‘Content-Disposition’] = ‘attachment;
filename=report.csv’
end

in rhtml:

Title,Value
<% @partners.each do |model| -%>
“<%= model.member_fname %>”,<%= model.member_lname %>
<% end -%>

[email protected] wrote:

I want to convert my data as CSV file. just i used simple coding, i

Check out this plugin:

http://svn.integralserver.com/plugins/to_csv/

It does all the hard work for you.

Eric

Eric A. wrote:

[email protected] wrote:

I want to convert my data as CSV file. just i used simple coding, i

Check out this plugin:

http://svn.integralserver.com/plugins/to_csv/

It does all the hard work for you.

Eric

hi,

thank u very much for your quick response. is there any other way
instead of plugin. because i can’t install this in client server

[email protected] wrote:

thank u very much for your quick response. is there any other way
instead of plugin. because i can’t install this in client server

Sure. Just do the same things this plugin does. I don’t understand why
you cannot install the plugin? Rails plugins are installed with the
project so if you can edit the project files you can install the plugin.

Eric

Here’s a simple example of using the CSV module, I’m fairly sure this
comes with the standard distribution of Ruby:

require ‘csv’
data = “”

CSV::Writer.generate(data) { |csv|
csv << ['data_item1,‘data_item2’]
}

File.open(OUTPUT_FILENAME, ‘w’) { |file| file << data }

DZ wrote:

Here’s a simple example of using the CSV module, I’m fairly sure this
comes with the standard distribution of Ruby:

require ‘csv’
data = “”

CSV::Writer.generate(data) { |csv|
csv << ['data_item1,‘data_item2’]
}

File.open(OUTPUT_FILENAME, ‘w’) { |file| file << data }

hi,

for this csv writer , have i to install anything, or simple this code
only will work. can u say please

I heard active_record extensions have a great .to_csv method, is that
the same as the CSV plugin mentioned above?

On Apr 26, 7:11 am, “François Beausoleil”

Hi !

2007/4/25, [email protected]
[email protected]:

I want to convert my data as CSV file. just i used simple coding, i
didn’t use fastercsv, because i installed in my system, but i couldn’t
see where it install, if i run also , it said there is no fastercsv
file. actaully i don’t know how to use that.

You might want to read my blog post on just this topic:
http://blog.teksol.info/articles/2006/03/23/returning-csv-data-to-the-browser

Hope that helps !

François Beausoleil
http://blog.teksol.info/
http://piston.rubyforge.org/

I checked and this is part of the standard library.

http://www.ruby-doc.org/stdlib/libdoc/csv/rdoc/index.html

François Beausoleil wrote:

Hi !

2007/4/25, [email protected]
[email protected]:

I want to convert my data as CSV file. just i used simple coding, i
didn’t use fastercsv, because i installed in my system, but i couldn’t
see where it install, if i run also , it said there is no fastercsv
file. actaully i don’t know how to use that.

You might want to read my blog post on just this topic:
http://blog.teksol.info/articles/2006/03/23/returning-csv-data-to-the-browser

Hope that helps !

Fran篩s Beausoleil
http://blog.teksol.info/
http://piston.rubyforge.org/

hi,

i saw ur link, actually i followed this link only the second step. i
got the answer. but it shows full of html coding in excel sheet. i want
to show only anser instead of html tags.

and now i am going to try this first step also. for the have we
install CSV:WRITER , or we can use like this.

     Thanks for ur help