
CSV parsing with Delphi 2010 handles CRLF in quoted fields
By: a guest on
Jun 24th, 2011 | syntax:
Delphi | size: 0.56 KB | hits: 266 | expires: Never
program Project29;
{$APPTYPE CONSOLE}
uses
SysUtils, Classes;
var L: TStringList;
aLine: string;
begin
L := TStringList.Create;
try
L.StrictDelimiter := True;
L.CommaText := '1997, Ford, E350,"Super, '#10#13'luxurious truck",Field,Field';
for aLine in L do
WriteLn('->', aLine);
finally L.Free;
end;
WriteLn;
WriteLn('Press ENTER to exit');
ReadLn;
end.
// Output looks like this:
// ->1997
// -> Ford
// -> E350
// ->Super,
// luxurious truck
// ->Field
// ->Field
//
// Press ENTER to exit