#1 2016-11-17 08:48:14

willo
Member
From: Cape Town, South Africa
Registered: 2014-11-15
Posts: 67
Website

CSV Parser ignoring blank fields

Hi AB,

When we recently required a CSV parser, I remembered that mORMot offered such a feature. We plugged in the CSVToRawUTF8DynArray function, but immediately started receiving issues. Some debugging revealed that blank field were ignored and investigating the code we saw:

procedure CSVToRawUTF8DynArray(CSV: PUTF8Char; var Result: TRawUTF8DynArray; Sep: AnsiChar = ',');
var s: RawUTF8;
begin
  while CSV<>nil do begin
    s := GetNextItem(CSV,Sep);
    if s<>'' then begin
      SetLength(Result,length(Result)+1);
      Result[high(Result)] := s;
    end;
  end;
end;

The line:

    if s<>'' then begin

seems like a bug to us, but I'm pretty sure you had some use case where you needed to ignore blank fields. This is, however, not part of the CSV standard (as much as CSV is a standard). Is there an alternative function to call or can we submit a fix?

Offline

Board footer

Powered by FluxBB