[Haskell-beginners] A problem with a simple csv file parser
Andy Elvey
andy.elvey at paradise.net.nz
Sat Oct 16 01:23:04 EDT 2010
Hi all -
I'm just trying to get the simple csv file parser from "Real World
Haskell" working.
However, I've got a problem. Here's the code -
-- A simple csv parser
Module parseCSV where
import Text.ParserCombinators.Parsec
csvFile = endBy line eol
line = sepBy cell (char ',')
cell = many (noneOf ",\n")
eol = char '\n'
parseCSV :: String -> Either ParseError [[String]]
parseCSV input = parse csvFile "(unknown)" input
( Btw, I'm running Ubuntu 10.04, GHC 6.12.1 )
When I try to run this (using "runhaskell parseCSV.hs test.csv" ) I get
the error -
parseCSV.hs:4:16: parse error on input `where'
This has me really puzzled - as far as I can see, the first line looks
identical to a number of similar
programs that I've found (while searching for a solution to this). So,
if anyone can let me know
what is causing this, that'd be great! Many thanks in advance -
- Andy
More information about the Beginners
mailing list