CSV parser from the lecture

21 views
Skip to first unread message

Dave Sands

unread,
Dec 4, 2015, 3:52:02 AM12/4/15
to 2015 Functional Programming TDA452/ DIT 142
The parser for CSV files from the lecture (which seems to work fine) is here.

Using the combinators that we built in Parsing library it can be rewritten in 5 lines as:

import Parsing
[comma,quote,newline] = ",\"\n"
csv  = zeroOrMore line 
line = chain cell (char comma) <-< char newline
cell = char quote >-> zeroOrMore (sat (/= quote)) <-< char quote
   +++ zeroOrMore (sat (`notElem` [comma,newline]))

Reply all
Reply to author
Forward
0 new messages