Board index » delphi » Importing Text Files

Importing Text Files

Hi,

I need to programatically import a text file into a PDOX file.  I've read
info on batch move and have a question.  The schema file must have the same
name as the text file.  My text file is being created from our mainframe by
users who can assign any valid file name they like.

I would like to display a form (or open dialog) that allows them to select
the file they downloaded, then read that into my PDOX file.

Thanks in advance for your help.
--
Thanks,

Lee Marrette
lmarre...@ramsay.com

 

Re:Importing Text Files


Two alternatives.

1) If you want to use BatchMove let the user select the text file then
copy a standard schema file and give it the correct name.

2) Write your own import routine.

Bill

(Sorry but TeamB cannot answer support questions received via email.)
(To send me email for any other reason remove .nospam from my address.)

Re:Importing Text Files


Not only must the schema have the same filename and extension .sch but
also must start with a [filename] line (filename is the name of the file
without extension).
If you want to read a delimited text file read read ti2844 document from
Borland support; it's the only correct, all other docs are wrong.

Quote
Bill Todd (TeamB) wrote:

> Two alternatives.

> 1) If you want to use BatchMove let the user select the text file then
> copy a standard schema file and give it the correct name.

> 2) Write your own import routine.

> Bill

> (Sorry but TeamB cannot answer support questions received via email.)
> (To send me email for any other reason remove .nospam from my address.)

Re:Importing Text Files


Good point.  The solution is to have the import program write the
schema file including the file name.

Bill

(Sorry but TeamB cannot answer support questions received via email.)
(To send me email for any other reason remove .nospam from my address.)

Re:Importing Text Files


I made a program that generates the .sch file that I need. It's the
only  workable way when you have many files with many fields.
The point is that this a brute force method. I lost a lot of time
figuring it all (yeah, I'm a dummy, so what?). The documentation is
wrong and partial and there should be an easier way to do it. If you
have a table with 45 fields (I have) you don't wan't to calculate the
offset by hand. What's the point of an offset in a delimited table?

Quote
Bill Todd (TeamB) wrote:

> Good point.  The solution is to have the import program write the
> schema file including the file name.

> Bill

> (Sorry but TeamB cannot answer support questions received via email.)
> (To send me email for any other reason remove .nospam from my address.)

Re:Importing Text Files


Quote
Alejandro Dobniewski <ado...@itron.com.ar.removethis> wrote:
>I made a program that generates the .sch file that I need. It's the
>only  workable way when you have many files with many fields.
>The point is that this a brute force method. I lost a lot of time
>figuring it all (yeah, I'm a dummy, so what?). The documentation is
>wrong and partial and there should be an easier way to do it. If you
>have a table with 45 fields (I have) you don't wan't to calculate the
>offset by hand. What's the point of an offset in a delimited table?

Hi Alejandro.

Quoting TI2844.
"For reading ASCII comma-delimited files, the length and offset
parameters for the field definitions do not apply to data values in the
ASCII files (as is the case for fixed-length field files), but to the
virtual fields, defined in the application, into which the values read
will be placed. The length parameter will need to reflect the maximum
length of the data value for each field -- not counting the delimiting
quotation marks or the comma separators. This is most difficult to
estimate for String type data values as the actual length of such a data
value may vary greatly from row to row in the ASCII data file. The
offset parameter for each field will not be the position of the data
value in the ASCII file (as is the case for fixed-length field files),
but the offset as represented by the cumulative length of all preceding
fields (again, the defined fields in memory, not the data values in the
ASCII file."

Now putting that aside since I did some work with importing ASCII tables
before I read it.  I have found that importing from ASCII tables (to
Paradox tables at least) does not require the Offset in a delimited
table.  I read the file ASCIIDRV.TXT.  Quoting:
"* Offset - Number of characters from the beginning of the line
  that the field begins.  Used for FIXED format only."

The given example of varying file format doesn't match with the above,
but I just put zero in the field offset in delimited files.  I suppose
it'll continue to work until the code is brought up to spec with the
docs (which one?).  :)

Regards,
Chris Roberts

Re:Importing Text Files


Quote
Chris Roberts wrote:
> The given example of varying file format doesn't match with the above,
> but I just put zero in the field offset in delimited files.  I suppose
> it'll continue to work until the code is brought up to spec with the
> docs (which one?).  :)

I suposse that day many programs will broke until programmers rethink
their code. After all, what docs do you believe in today? ;-)

Other Threads