From: Robert Klemme on
2010/7/1 James Edward Gray II <james(a)graysoftinc.com>:
> On Jun 30, 2010, at 10:41 AM, Brian Candler wrote:
>
>> James Edward Gray II wrote:
>>> I'm open to suggestions and I do take patches.
>>
>> Specifically, I'd like to see how to parse CSV from stdin. You provide
>> an example in the opposite direction:
>>
>> #   FCSV($stderr)    { |csv_err| csv_err << %w{my data here} }  # to
>> $stderr
>
> On Jun 30, 2010, at 11:35 AM, Robert Klemme wrote:
>
>> On 30.06.2010 17:05, James Edward Gray II wrote:
>>>
>>> Do you think it would help if I added Wrapping an IO under the
>>> Shortcut Interface on this page?
>>>
>>> http://fastercsv.rubyforge.org/classes/FasterCSV.html
>>
>> +1
>
> 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

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

From: Robert Klemme on
2010/7/1 Robert Klemme <shortcutter(a)googlemail.com>:
> 2010/7/1 James Edward Gray II <james(a)graysoftinc.com>:
>> On Jun 30, 2010, at 10:41 AM, Brian Candler wrote:
>>
>>> James Edward Gray II wrote:
>>>> I'm open to suggestions and I do take patches.
>>>
>>> Specifically, I'd like to see how to parse CSV from stdin. You provide
>>> an example in the opposite direction:
>>>
>>> #   FCSV($stderr)    { |csv_err| csv_err << %w{my data here} }  # to
>>> $stderr
>>
>> On Jun 30, 2010, at 11:35 AM, Robert Klemme wrote:
>>
>>> On 30.06.2010 17:05, James Edward Gray II wrote:
>>>>
>>>> Do you think it would help if I added Wrapping an IO under the
>>>> Shortcut Interface on this page?
>>>>
>>>> http://fastercsv.rubyforge.org/classes/FasterCSV.html
>>>
>>> +1
>>
>> 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

Btw, this inspired me to http://gist.github.com/459749

:-)

Cheers

robert


--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

From: Brian Candler on
James Edward Gray II wrote:
> Better?
>
> http://fastercsv.rubyforge.org/classes/FasterCSV.html

Yes, that's just the reminder I need :-) Thanks.
--
Posted via http://www.ruby-forum.com/.

From: James Edward Gray II on
On Jul 1, 2010, at 4:02 AM, Robert Klemme wrote:

> 2010/7/1 James Edward Gray II <james(a)graysoftinc.com>:
>> On Jun 30, 2010, at 10:41 AM, Brian Candler wrote:
>>
>>> James Edward Gray II wrote:
>>>> I'm open to suggestions and I do take patches.
>>>
>>> Specifically, I'd like to see how to parse CSV from stdin. You provide
>>> an example in the opposite direction:
>>>
>>> # FCSV($stderr) { |csv_err| csv_err << %w{my data here} } # to
>>> $stderr
>>
>> On Jun 30, 2010, at 11:35 AM, Robert Klemme wrote:
>>
>>> On 30.06.2010 17:05, James Edward Gray II wrote:
>>>>
>>>> Do you think it would help if I added Wrapping an IO under the
>>>> Shortcut Interface on this page?
>>>>
>>>> http://fastercsv.rubyforge.org/classes/FasterCSV.html
>>>
>>> +1
>>
>> 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

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 Gray II


From: Robert Klemme on
On 01.07.2010 16:14, James Edward Gray II wrote:
> On Jul 1, 2010, at 4:02 AM, Robert Klemme wrote:
>
>> 2010/7/1 James Edward Gray II<james(a)graysoftinc.com>:
>>> On Jun 30, 2010, at 10:41 AM, Brian Candler wrote:
>>>
>>>> James Edward Gray II wrote:
>>>>> I'm open to suggestions and I do take patches.
>>>>
>>>> Specifically, I'd like to see how to parse CSV from stdin. You
>>>> provide an example in the opposite direction:
>>>>
>>>> # FCSV($stderr) { |csv_err| csv_err<< %w{my data here} }
>>>> # to $stderr
>>>
>>> On Jun 30, 2010, at 11:35 AM, Robert Klemme wrote:
>>>
>>>> On 30.06.2010 17:05, James Edward Gray II wrote:
>>>>>
>>>>> Do you think it would help if I added Wrapping an IO under
>>>>> the Shortcut Interface on this page?
>>>>>
>>>>> http://fastercsv.rubyforge.org/classes/FasterCSV.html
>>>>
>>>> +1
>>>
>>> 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
>
> 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"]

Good point. Thank you for consideration of my suggestion.

Kind regards

robert

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
First  |  Prev  | 
Pages: 1 2 3 4 5
Prev: Trying to reach Florian Frank
Next: can't use uki