[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: a question about csv parser
- From: roberto@... (Roberto Ierusalimschy)
- Date: Thu, 13 Sep 2007 08:44:49 -0300
> I have a question about csv parser.
> For most of the codes I can search(including lpeg and
> even python's module), they show how to break a
> "record" or csv line into fields.
> Now if I have a file like the following :
> "this is a field with \r\n", 2, 3 \r\n
> normal, 2, 3 \r\n
> how do I read the correct line as the quoted \r\n
> would not be treated specially by io:lines(), I
If your file is not huge, you can read (and decode) it all at once:
filep = lpeg.Ct(lpeg.Ct(record)^0)
result = filep:match(io.read("*all"))