Hacky patch to fix this for future reference, against bytestring-csv-0.1.2, cost center annotations used to anecdotally verify that the change doesn't significantly impact performance, (interestingly the Alex lexer in bytestring-csv appears to allocate 1.5GB while lexing a 1.6MB csv file!?)<div>
<br></div><div>Text/CSV/ByteString.hs </div><div><br></div><div><div>65c65</div><div>< fields = [ unquote s | Item s <- line ]</div><div>---</div><div>> fields = [ unquote s | Item s <- pline line]</div>
<div>76a77,86</div><div>> </div><div>> </div><div>> pline fs@(Item x : []) = fs</div><div>> pline (Item x : Comma : []) = {-# SCC "plinea" #-} Item x : Comma : Item S.empty : []</div><div>> pline (Item x : Comma : rs) = {-# SCC "plineb" #-} Item x : Comma : pline rs</div>
<div>> pline (Comma : []) = {-# SCC "plinec" #-} Comma : Item S.empty : Comma : Item S.empty : []</div><div>> pline (Comma : rs) = {-# SCC "plined" #-} Item S.empty : Comma : pline rs</div><div>> pline (Newline : rs ) = []</div>
<div>> pline [] = [] </div><div>> </div><div><br></div><br><div class="gmail_quote">On 17 February 2012 23:16, Tom Doris <span dir="ltr"><<a href="mailto:tomdoris@gmail.com">tomdoris@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>the bytestring-csv package appears to have a bug whereby empty fields are dropped completely from the row, which is different to Text.CSV , which will return an empty field in the parse result. I'd argue this is a bug in bytestring-csv, anyone know whether this has been raised before, or know of a workaround?</div>
<br><div><div>Prelude Data.Maybe Data.List Text.CSV.ByteString Data.ByteString.Char8> parseCSV $ pack "a,b,c\n1,2,3\n1,,9\n"</div><div>Just [["a","b","c"],["1","2","3"],["1","9"]]</div>
</div><div><br></div><div>-- the last row has two fields ^</div><div><br></div><div><div>Prelude Text.CSV> parseCSV "/tmp/err" "a,b,c\n1,2,3\n1,,9\n"</div><div>Right [["a","b","c"],["1","2","3"],["1","","9"],[""]]</div>
</div><div><br></div><div><br></div>
</blockquote></div><br></div>