-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED]]On Behalf Of Simon Mahony
>Sent: Monday, 14 August 2000 11:20
>To: Multiple recipients of list database
>Subject: [DUG-DB]: Loading Interbase from text / CSV files
>
>
>I'm sure I read somewhere that you can read and write data to and from
>Interbase via CSV (comma separated text) files.
>Does anyone know how to do this. I can't find it in the docs.
>
>Cheers,
>Simon Mahony.
I do not know of any way of reading or writing CSV text directly to
IB, but I know that you can use CREATE TABLE to read fixed-width record
formats of type char. (not sure about / haven't tried writing to them.)
An example for a file called "c:\tmp\people.txt", where the contents are
---BOF---
123Jones John <CRLF>
456Bloggs Joseph <CRLF>
789Smith John <CRLF>
---EOF---
would be:
CREATE TABLE People
EXTERNAL FILE "C:\Tmp\People.txt"
(
Code CHAR(3),
LastName CHAR(20),
FirstName CHAR(20),
CRLF CHAR(2)
);
Considerations: Interbase reads the file byte-wise rather than in
lines of text. Some text editors and the like trim trailing spaces,
so you may need to put a placeholder char before the CRLF at the end
of each line. In this case the last field would be declared with size
3. A "select * from ..." will show up alignment problems.
I don't think you can index or set constraints on the external table,
so the next step is usually to Insert the data from this table into a
standard Interbase table for further processing.
All up, it's probably better to implement imports / exports in Delphi.
Many reporting engines provide 'print to CSV' functionality, and often.
Regards,
Cory Shanks
PayGlobal: Innovative people management solutions - that work for you
http://www.payglobal.com/
TimeMaster Systems Limited
Level 1, 8 Nelson Street, PO Box 8198
Riccarton, Christchurch, New Zealand
Phone: 64 3 343 3835 Fax: 64 3 343 3953
Mobile: 021 119 0356
Email: mailto:[EMAIL PROTECTED]
---------------------------------------------------------------------------
New Zealand Delphi Users group - Database List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz