I was recently confronted with the fact that the Borland Database System Utility does not export the TEXT and BLOB columns to a .CSV
file.
I searched online, and did not find anything very concrete that was free.
For those who run into a similar situation, here is how I solved it (I am also ready to export the data for you – in which case, send me a message):
-
Install Delphi 6 (or any version that you have access to)
-
Place a
TDBISAMDatabase
object on your form, and set the propertyDirectory
to the folder in which you have your DBISAM tables -
Place a
TDBISAMQuery
object on the form, and set the propertyDatabase
to the name of theTDBISAMDatabase
object. -
Place a button on the form, and double click it to go the the button’s click event. Paste, and adapt the code to the columns in your table, the following code:
var myFile : TextFile; begin AssignFile(myFile, 'filename_of_export_data.csv'); ReWrite(myFile); // Use the pipe "|" as column delimiter Writeln(myFile,'ID|Genus'); // Specify the column headers here QueryMain.SQL.Text := 'SELECT * FROM your_table_name '; QueryMain.Open; with QueryMain do begin First; while not eof do begin Writeln(myFile, FieldByName('FNId').AsString + '|' + QuotedStr(Utf8Encode(StringReplace(FieldByName('Name').AsString, #10#13, '', [rfReplaceAll]))) ); Next; end; end; CloseFile(myFile);
To export the images, place a another button on the form, double click it to open the button’s click event, and paste the following code:
var
Strm: TFileStream;
begin
QueryMain.SQL.Text := 'SELECT * FROM your_table_name '; //
QueryMain.Open;
with QueryMain do
begin
First;
while not eof do
begin
// adapt the following code to the table's image field name
Strm := TFileStream.Create('C:DelphiDelphi ProjectsHerbariumExportImagesimage_'+FieldByName('FNId').AsString+'_'+FieldByName('FNHerbariumId').AsString+'.jpg', fmCreate);
try
(FieldByName('FNImage') AS TBlobField).SaveToStream(Strm);
finally
Strm.Free;
end;
Next;
end;
end;
The above worked with Delphi version 6. It exported the TEXT columns, and also the images which were stored as BLOB columns