Phil Dawes | 19 Apr 22:58

csv parser (and git troubles)

Hi Slava, Hi factor list,

I've been experimenting with git and have put a factor repository on my 
webspace which contains the csv parser vocab I wrote a few months ago.

http://phildawes.net/2008/factor.git

Unfortunately when I try to pull I get:

$ git pull http://phildawes.net/2008/factor.git
error: pick-rref: HEAD not found
No such ref HEAD at http://phildawes.net/2008/factor.git

Which I don't understand because HEAD is readable. I suspect it may be 
the same problem as here[1]. Anyway, pulling the master branch 
explicitly appears to work:

$ git pull http://phildawes.net/2008/factor.git master
Fetching refs/heads/master from http://phildawes.net/2008/factor.git 
using http
got b2e540e2a92df1cb7bf6ee15ddf678e7d14379ed
walk b2e540e2a92df1cb7bf6ee15ddf678e7d14379ed
got e136ec03c40ee883c2504726489e68498d7bf3c4
... etc...

Is this sufficient for inclusion into the main factor repo?
Also what's the usual protocol for getting stuff included into Slava's 
factor repo - do people email privately?

Thanks,
(Continue reading)

Stefan Scholl | 30 Apr 11:13
Picon
Favicon

Re: csv parser (and git troubles)

The definition of (csv) uses a hardcoded "CHAR: ,", which
prevents it from being used with the CSV output of the German
version of Excel.

I know that a CSV with semicolon instead of comma is broken, but
when you tell someone to "just send a CSV" file, then you end up
with it. Reality is evil.

--

-- 
Web (en): http://www.no-spoon.de/ -*- Web (de): http://www.frell.de/

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
Phil Dawes | 30 Apr 15:26

Re: csv parser (and git troubles)

Hi Stefan,

Stefan Scholl wrote:
> The definition of (csv) uses a hardcoded "CHAR: ,", which
> prevents it from being used with the CSV output of the German
> version of Excel.
> 
> I know that a CSV with semicolon instead of comma is broken, but
> when you tell someone to "just send a CSV" file, then you end up
> with it. Reality is evil.
> 

I'll create a version that lets you specify the delimiter on the train 
home from work. I'm guessing making it a variable may impact performance 
(I'm using the module for importing large files) but then if that's a 
problem I could always specialize a version for commas using a 
compiler-transform or something.

Cheers,

Phil

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
Phil Dawes | 30 Apr 20:29

csv delimiter option (was: Re: csv parser (and git troubles))

Hi Stefan, Hi factor list,

I added a with-delimiter word to the csv vocab which changes the field
delimiter used by the parser.
e.g.

.. <file-reader> CHAR: \t [ csv ] with-delimiter

You can pull the code from my git repo:

   git pull http://phildawes.net/2008/factor.git master

I'm not sure if with-delimiter is a good interface or not. The other
options were:

2. have csv and csv-row take a delimiter from the stack
3. have the client explicitly set the delimiter variable

(2) looks cleaner, but is less clean for the default case.
(3) exposes more internals but has the advantage that if the csv parser
is expanded with other options the interface doesn't change. N.B. I
noticed that the python csv parser has quite a few options so this is
likely to happen at some point.

What do you think? Is there a recommended 'factor-way' for handling
optional arguments to words?

Cheers,

Phil
(Continue reading)

Slava Pestov | 30 Apr 21:12

Re: csv delimiter option (was: Re: csv parser (and git troubles))

Thanks, I've merged your changes.

I think with-delimiters is fine. Another approach is to have csv and  
csv-row take a 'configuration' object. One example of this idiom is  
the io.launcher vocabulary; if you look at run-process, it can either  
take a string or a process tuple with half a dozen possible slots  
which can be set.

Looking forward to more contributions!

Slava

On Apr 30, 2008, at 1:29 PM, Phil Dawes wrote:

> Hi Stefan, Hi factor list,
>
> I added a with-delimiter word to the csv vocab which changes the field
> delimiter used by the parser.
> e.g.
>
> .. <file-reader> CHAR: \t [ csv ] with-delimiter
>
> You can pull the code from my git repo:
>
>   git pull http://phildawes.net/2008/factor.git master
>
> I'm not sure if with-delimiter is a good interface or not. The other
> options were:
>
> 2. have csv and csv-row take a delimiter from the stack
(Continue reading)

Stefan Scholl | 1 May 00:16
Picon
Favicon

Re: csv delimiter option

Phil Dawes <phil@...> wrote:
> I added a with-delimiter word to the csv vocab which changes the field
> delimiter used by the parser.
> e.g.
> 
> .. <file-reader> CHAR: \t [ csv ] with-delimiter
> 
...
> I'm not sure if with-delimiter is a good interface or not. The other

Python's csv module has a whole bunch of parameters:
http://docs.python.org/lib/csv-fmt-params.html#csv-fmt-params

But I don't remember needing anything more than just an other
delimiter.

--

-- 
Web (en): http://www.no-spoon.de/ -*- Web (de): http://www.frell.de/

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

Gmane