[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] FasterCSV 1.0.0 -- The "Sorry it's late, Ara" release!

James Gray

11/5/2006 10:44:00 PM

FasterCSV 1.0.0 Released
========================

Ara strikes again, adding his second awesome enhancement to
FasterCSV. Here's some example code showing off FasterCSV::Table:

#!/usr/local/bin/ruby -w

# csv_table.rb
#
# Created by James Edward Gray II on 2006-11-04.
# Copyright 2006 Gray Productions. All rights reserved.
#
# Feature implementation and example code by Ara.T.Howard.

require "faster_csv"

table = FCSV.parse(DATA, :headers => true, :header_converters
=> :symbol)

# row access
table[0].class # => FasterCSV::Row
table[0].fields # => ["zaphod", "beeblebrox", "42"]

# column access
table[:first_name] # => ["zaphod", "ara"]

# cell access
table[1][0] # => "ara"
table[1][:first_name] # => "ara"
table[:first_name][1] # => "ara"

# manipulation
table << %w[james gray 30]
table[-1].fields # => ["james", "gray", "30"]

table[:type] = "name"
table[:type] # => ["name", "name", "name"]

table[:ssn] = %w[123-456-7890 098-765-4321]
table[:ssn] # => ["123-456-7890", "098-765-4321", nil]

# iteration
table.each do |row|
# ...
end

table.by_col!
table.each do |col_name, col_values|
# ...
end

# output
puts table
# >> first_name,last_name,age,type,ssn
# >> zaphod,beeblebrox,42,name,123-456-7890
# >> ara,howard,34,name,098-765-4321
# >> james,gray,30,name,

__END__
first_name,last_name,age
zaphod,beeblebrox,42
ara,howard,34

Thank you Ara!

What is FasterCSV?
------------------

(from the README)

FasterCSV is intended as a replacement to Ruby's standard CSV library.
It was designed to address concerns users of that library had and it has
three primary goals:

1. Be significantly faster than CSV while remaining a pure Ruby
library.
2. Use a smaller and easier to maintain code base. (FasterCSV is
larger now,
but considerably richer in features. The parsing core remains
quite small.)
3. Improve on the CSV interface.

What's New?
-----------

(highlights from the CHANGELOG)

* The slurping methods now return the new FasterCSV::Table objects.
* Fixed parser so multibyte :col_sep works now.
* Fixed FasterCSV.rewind() to reset the FasterCSV.lineno() counter.
* Fixed FasterCSV.rewind() to reset the header processing.
* Enhanced FasterCSV::Row.fields() to support Ranges, even for headers.
* Added a few examples for usage.

Migrating from CSV to FasterCSV?
--------------------------------

The README includes a section on the differences and you can read that
here:

http://fastercsv.ruby...

You call also see general usage in the documentation of the interface,
right here:

http://fastercsv.ruby...classes/FasterCSV.html

For quick and dirty switching, try:

begin
require "faster_csv"
FasterCSV.build_csv_interface
rescue LoadError
require "csv"
end
# ... use CSV here ...

If FasterCSV isn't meeting your needs, I want to here about it:

james@grayproductions.net

Where can I learn more?
-----------------------

FasterCSV is hosted on RubyForge.

Project page: http://rubyforge.org/projects/...
Documentation: http://fastercsv.ruby...
Downloads: http://rubyforge.org/frs/?gro...

How do I get FasterCSV?
-----------------------

FasterCSV is a gem, so as long as you have RubyGems installed it's as
simple as:

$ sudo gem install fastercsv

If you need to install RubyGems, you can download it from:

http://rubyforge.org/frs/?group_id=126&relea...

FasterCSV can also be installed manually. Just download the latest
release and follow the instructions in INSTALL:

http://rubyforge.org/frs/?gro...&release_id=7740

James Edward Gray II


3 Answers

Ara.T.Howard

11/6/2006 6:36:00 PM

0

Gregory Brown

11/8/2006 2:33:00 AM

0

On 11/5/06, James Edward Gray II <james@grayproductions.net> wrote:
> FasterCSV 1.0.0 Released
> ========================
>
> Ara strikes again, adding his second awesome enhancement to
> FasterCSV. Here's some example code showing off FasterCSV::Table:

Congrats on a 1.0 release James! Great work. And Ara, your additions rock.

1,987 murdered in Obama's organized communities

7/21/2013 11:49:00 AM

0

On Sat, 20 Jul 2013 22:15:59 -0700, Bill Shatzer <wws38@NOcornell.edu>
wrote:

>hal lillywhite wrote:
>
>> With Obama, Holder, Sharpton and the news making a big deal out of the supposed racism in
>> the US, a bit of actual data shows quite a different picture. Going by willingness to accept
>> neighbors of a different ethnicity, the US is among the least racist countries in the world.
>
>> http://rare.us/story/trayvon-aside-study-shows-u-s-one-of-the-least-racist-...
>
>It's not considered politically or socially correct to admit to racism,
>even to a poll taker.
>
>See, for instance, the so-called "Bradley effect".
>
>Be guided by what people do, not by what they say.

Had a discussion (okay, was subjected to a rant) today with a very
liberal acquaintance. He "really hoped something bad happened to Joe
Zimmerman".

He was not pleased when I pointed out how 'Klan' he sounded...