Convert object properties to delimited string and save results to file
Posted on 2011-03-24
Suppose we have a Customer obj with the following properties:
I would like to Convert object properties to delimited string with a object method like:
function Customer.ToString(const aDelimiter: Char): string;
//SAmple code for csv, need change to use aDelimiter parameter
Result := Format("%s,%s,%s",Id, Name, Description);
where aDelimiter can be ",", ";", tab(\t), etc.
Notice that the result string will be stored in a stringlist later on to be output to a file. For example the Pseudo code:
csvList := TStringList.Create;
foreach customer in CustomerList
There are thousands of lines to store from CustomerList, any ideas on how to make it this export more efficient will be greatly appreciated.
Note: Compiler is still Delphi 7.