Want more features on Pastebin? Sign Up, it's FREE!
Guest

CSV parsing with Delphi 2010 handles CRLF in quoted fields

By: a guest on Jun 24th, 2011  |  syntax: Delphi  |  size: 0.56 KB  |  views: 279  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. program Project29;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6.   SysUtils, Classes;
  7.  
  8. var L: TStringList;
  9.     aLine: string;
  10. begin
  11.   L := TStringList.Create;
  12.   try
  13.     L.StrictDelimiter := True;
  14.     L.CommaText := '1997, Ford, E350,"Super, '#10#13'luxurious truck",Field,Field';
  15.     for aLine in L do
  16.       WriteLn('->', aLine);
  17.   finally L.Free;
  18.   end;
  19.  
  20.   WriteLn;
  21.   WriteLn('Press ENTER to exit');
  22.   ReadLn;
  23. end.
  24.  
  25. // Output looks like this:
  26.  
  27. // ->1997
  28. // -> Ford
  29. // -> E350
  30. // ->Super,
  31. // luxurious truck
  32. // ->Field
  33. // ->Field
  34. //
  35. // Press ENTER to exit
clone this paste RAW Paste Data