什么是Ruby 1.9标准CSV库? [英] What is Ruby 1.9 standard CSV library?

查看:97
本文介绍了什么是Ruby 1.9标准CSV库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在我的应用程序上尝试FasterCSV宝石时遇到此错误:

 请切换到Ruby 1.9的标准
CSV库。它是FasterCSV加
支持Ruby 1.9的m17n编码
引擎。

顺便说一下,我使用Rails 3,Ruby 1.9.2和Rubygems 1.4。 / p>

有人可以向我解释如何使用Ruby 1.9的标准CSV库。我不会
有任何想法,因为我是非常新的Rails。

解决方案

Ruby 1.9采用FasterCSV作为其内置的CSV库。但是,它在标准库而不是Ruby 1.9的核心,所以你需要在你的应用程序中手动需要它。



添加

  require'csv'

到您的代码,然后可以执行

  CSV.parse(this,is,my,data) 

查看 Ruby 1.9的标准库CSV文档了解有关使用库的信息。


When I try the FasterCSV gem on my application I get this error:

Please switch to Ruby 1.9's standard
CSV library.  It's FasterCSV plus
support for Ruby 1.9's m17n encoding
engine.

By the way, I'm using Rails 3, Ruby 1.9.2, and Rubygems 1.4.

Can someone explain to me please how to use the standard CSV library for Ruby 1.9. I don't have any idea at all because I'm very new to Rails.

解决方案

Ruby 1.9 has adopted FasterCSV as its built-in CSV library. However, it's in the standard library rather than Ruby 1.9's core, so you need to manually require it in your application.

After adding a

require 'csv'

to your code, you can then do things such as

CSV.parse("this,is,my,data")

See Ruby 1.9's standard library CSV documentation for information on using the library.

这篇关于什么是Ruby 1.9标准CSV库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆