djames
July 1, 2010, 11:02am
21
2010/7/1 James Edward G. II [email protected] :
Better?
http://fastercsv.rubyforge.org/classes/FasterCSV.html
Perfect! Do you think it is a good idea to also allow an IO as
argument to foreach so we can save a block?
FCSV($stdin) { |csv_in| csv_in.each { |row| p row } } # from
$stdin
would become
FCSV.foreach($stdin) { |row| p row } # from $stdin
Kind regards
robert
djames
July 1, 2010, 11:05am
22
2010/7/1 Robert K. [email protected] :
$stderr
+1
would become
FCSV.foreach($stdin) { |row| p row } # from $stdin
Btw, this inspired me to Toy example of simpler loop nesting · GitHub
Cheers
robert
djames
July 1, 2010, 4:15pm
23
On Jul 1, 2010, at 4:02 AM, Robert K. wrote:
$stderr
+1
would become
FCSV.foreach($stdin) { |row| p row } # from $stdin
I would rather not go that far. The standard CSV library for Ruby 1.8
varied its interface slightly from the IO methods I assumed it meant to
imitate. For example, open() was essentially foreach() when you passed
an “r” mode. This always bothered me.
We don’t need two blocks though. I showed it that way in the
documentation for consistency (to hopefully make it easier to remember),
but this works:
$ echo -e ‘a,b,c’ | ruby -rubygems -e ‘require “faster_csv”;
FCSV($stdin).each { |row| p row }’
[“a”, “b”, “c”]
James Edward G. II
djames
July 1, 2010, 11:26am
24
James Edward G. II wrote:
Better?
http://fastercsv.rubyforge.org/classes/FasterCSV.html
Yes, that’s just the reminder I need Thanks.
djames
July 1, 2010, 11:15pm
25
On 01.07.2010 16:14, James Edward G. II wrote:
http://fastercsv.rubyforge.org/classes/FasterCSV.html
FCSV($stdin) { |csv_in| csv_in.each { |row| p row } } # from
We don’t need two blocks though. I showed it that way in the
documentation for consistency (to hopefully make it easier to
remember), but this works:
$ echo -e ‘a,b,c’ | ruby -rubygems -e ‘require “faster_csv”;
FCSV($stdin).each { |row| p row }’ [“a”, “b”, “c”]
Good point. Thank you for consideration of my suggestion.
Kind regards
robert