parse returns a lazy seq of vectors, delimiter support, parsing strings. #2

Merged
merged 6 commits into from May 23, 2011

Projects

None yet

2 participants

@RobinRamael
Contributor

Hi,

I added the possibility to let parse return a lazy-seq of vectors instead of maps,
added basic support for using custom delimiters and support for parsing strings instead of just reading from files.
I hope this project isn't dead, it's the only parser that worked for me...
(disregard the ither pull requet I closed, there were problems with it)

Robin

RobinRamael added some commits May 21, 2011
@RobinRamael RobinRamael parse can returns vectors and custom delimiters
Added the possibility to let parse return a lazy-seq of vectors instead of maps and
added supprt for using custom delimiters.
05cbbd3
@RobinRamael RobinRamael Added support for stringparsing instead of only reading from files. 145c856
Owner

Not at all, I just haven't seen this code for a while

Do you feel that instead of adding multiple readers, i.e. for files, strings, urls etc it could be made more general? Just accepting reader for instance.

Also the vectors is a good idea, how bout trying optional keyword params instead of arguments. That way it could be changed later to allow more options without breaking existing code.

@grinnbearit grinnbearit reopened this May 22, 2011
Contributor

You're right, just accepting a reader and arguments would be best.
I see the usage then being something like (csv/parse reader :mapped (true/false) :delimiter \; :end-of-line \\r).

I probably pushed this too soon, as i'm still figuring out what I need the parser to do myself. I'll push my work to this request when I'm sure.

Owner

sounds good,
(defn parse [reader & {:keys [mapped delimiter end-of-line] :or {mapped
false delimiter , end-of-line \r}]
...)

On Sun, May 22, 2011 at 5:07 PM, RobinRamael <
reply@reply.github.com>wrote:

You're right, just accepting a reader and arguments would be best.
maybe something like (parse reader :mapped (true/false) :delimiter ;
:end-of-line \r) ?

I probably pushed this too soon, as i'm still figuring out what I need the
parser to do myself. I'll push my work to this request when I'm sure.

Reply to this email directly or view it on GitHub:
#2 (comment)

RobinRamael added some commits May 22, 2011
@RobinRamael RobinRamael Parse now takes a reader and options.
This restructures the ideas of my last two commits:
- Parse now takes a reader and the options :mapped, :delimiter and :quoter.
- Added two helper-functions parse-file and parse-string which take a
  filename and a string resp.
- Updated the documentation for those functions.
4bc3e35
@RobinRamael RobinRamael Added tests. 24313df
@RobinRamael RobinRamael Updated README. 10aa3c9
Contributor

There we go. I've implemented the parse function with the options, added the parse-file and parse-string helper-functions, added tests and updated the readme.

@grinnbearit grinnbearit merged commit d17346e into grinnbearit:master May 23, 2011
Owner

looks great! merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment