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&#39;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>&lt;         fields       = [ unquote s | Item s &lt;- line ]</div><div>---</div><div>&gt;         fields       = [ unquote s | Item s &lt;- pline line]</div>
<div>76a77,86</div><div>&gt; </div><div>&gt; </div><div>&gt; pline fs@(Item x : []) = fs</div><div>&gt; pline (Item x : Comma : []) = {-# SCC &quot;plinea&quot; #-} Item x : Comma : Item S.empty :  []</div><div>&gt; pline (Item x : Comma : rs) = {-# SCC &quot;plineb&quot; #-} Item x : Comma : pline rs</div>
<div>&gt; pline (Comma : []) = {-# SCC &quot;plinec&quot; #-} Comma : Item S.empty : Comma : Item S.empty : []</div><div>&gt; pline (Comma : rs) = {-# SCC &quot;plined&quot; #-} Item S.empty : Comma : pline rs</div><div>&gt; pline (Newline : rs ) = []</div>
<div>&gt; pline [] = [] </div><div>&gt; </div><div><br></div><br><div class="gmail_quote">On 17 February 2012 23:16, Tom Doris <span dir="ltr">&lt;<a href="mailto:tomdoris@gmail.com">tomdoris@gmail.com</a>&gt;</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&#39;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&gt; parseCSV $ pack &quot;a,b,c\n1,2,3\n1,,9\n&quot;</div><div>Just [[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;],[&quot;1&quot;,&quot;2&quot;,&quot;3&quot;],[&quot;1&quot;,&quot;9&quot;]]</div>

</div><div><br></div><div>-- the last row has two fields ^</div><div><br></div><div><div>Prelude Text.CSV&gt; parseCSV &quot;/tmp/err&quot; &quot;a,b,c\n1,2,3\n1,,9\n&quot;</div><div>Right [[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;],[&quot;1&quot;,&quot;2&quot;,&quot;3&quot;],[&quot;1&quot;,&quot;&quot;,&quot;9&quot;],[&quot;&quot;]]</div>

</div><div><br></div><div><br></div>
</blockquote></div><br></div>