Board index » delphi » Need Help making Ascii File into Table!

Need Help making Ascii File into Table!

All I am trying to do is take a comma-separated Ascii file and convert it
into an Ascii or Paradox table.  The commas serve as field separators and a
line-feed character serves as a record terminator.  There are no carriage
return characters in the file.

Reading the file byte-by-byte is out of the question because the size of
the file (sometimes 50MB) causes this to take way too long.

When I try to connect a TTable to the file with the TableType property set
to ttAscii, everything ends up in a single field.  Also, I cannot seem to
connect to files that are larger than 32K.  TMemos have this limitation as
well.

Any ideas anyone??  Please respond via e-mail to bwe...@interactix.com.

Thanks in advance,

Brian.

 

Re:Need Help making Ascii File into Table!


Here's the concept I use for doing just that.

Read in a line, copy the data from the first char to pos of the comma then
delete the same.
Run this in a loop until there are on more comma's.
output via watch is something like this

field1 := ''
field2 := ''
field3 := ''
linein := 'data1,data2,data3'

field1 := 'data1'
field2 := ''
field3 := ''
linein := 'data2,data3'

field1 := 'data1'
field2 := 'data2'
field3 := ''
linein := 'data3'

Once you have your line broke down, write to your db and read the next
line.

Be sure to clear all the vars before each loop or your data will be wrong.

I have some code if you need it.

Hope this helps.

 Brian Weith wrote in article <01bc82ae$a8353170$3102a4cd@bwntpc>...

Quote
>All I am trying to do is take a comma-separated Ascii file and convert it
>into an Ascii or Paradox table.  The commas serve as field separators and
a
>line-feed character serves as a record terminator.  There are no carriage
>return characters in the file.

>Reading the file byte-by-byte is out of the question because the size of
>the file (sometimes 50MB) causes this to take way too long.

>When I try to connect a TTable to the file with the TableType property
set
>to ttAscii, everything ends up in a single field.  Also, I cannot seem to
>connect to files that are larger than 32K.  TMemos have this limitation
as
>well.

>Any ideas anyone??  Please respond via e-mail to bwe...@interactix.com.

>Thanks in advance,

>Brian.

Re:Need Help making Ascii File into Table!


Quickest way is to get Borland Paradox 5.0 or 7.0. The 'import expert' will
do it for you automatically.

Second way is to use the file function of Delphi (assignfile, readln,
write, ...) see Delphi Help.

Eric BELTRANDO
COGISOFT - PARIS

Brian Weith <bwe...@mcs.com> a crit dans l'article
<01bc82ae$a8353170$3102a4cd@bwntpc>...

Quote
> All I am trying to do is take a comma-separated Ascii file and convert it
> into an Ascii or Paradox table.  The commas serve as field separators and

a
...
Quote
> Any ideas anyone??  Please respond via e-mail to bwe...@interactix.com.

> Thanks in advance,

> Brian.

Re:Need Help making Ascii File into Table!


Quote
"Brian Weith" <bwe...@mcs.com> wrote:

What you have to do is generate a .sch file that goes together with
you ascii file. You can read more about this in the TI docs at
borlands website.

Cheers
Conrad Smith

sm...@suntiger.ee.up.ac.za

Quote
>All I am trying to do is take a comma-separated Ascii file and convert it
>into an Ascii or Paradox table.  The commas serve as field separators and a
>line-feed character serves as a record terminator.  There are no carriage
>return characters in the file.
>Reading the file byte-by-byte is out of the question because the size of
>the file (sometimes 50MB) causes this to take way too long.
>When I try to connect a TTable to the file with the TableType property set
>to ttAscii, everything ends up in a single field.  Also, I cannot seem to
>connect to files that are larger than 32K.  TMemos have this limitation as
>well.
>Any ideas anyone??  Please respond via e-mail to bwe...@interactix.com.
>Thanks in advance,
>Brian.

Re:Need Help making Ascii File into Table!


On 27 Jun 1997 04:02:03 GMT, "Brian Weith" <bwe...@mcs.com> wrote:

Quote
>All I am trying to do is take a comma-separated Ascii file and convert it
>into an Ascii or Paradox table.  The commas serve as field separators and a
>line-feed character serves as a record terminator.  There are no carriage
>return characters in the file.

>Reading the file byte-by-byte is out of the question because the size of
>the file (sometimes 50MB) causes this to take way too long.

You can read in a full buffer of say 32K or 64K (or whatever you
like), then parse in memory. Reading will take far less than reading
byte by byte.

Desde la ciudad de Mexico (and willing to relocate to Canada)
Raul Suarez

Re:Need Help making Ascii File into Table!


There is also  CommaText  property of a stringlist which splits a
comma-delimited string down into its component strings

Quote
"Kevin Brown" <kbr...@micro.ti.com> wrote:
>Here's the concept I use for doing just that.
>Read in a line, copy the data from the first char to pos of the comma then
>delete the same.
>Run this in a loop until there are on more comma's.
>output via watch is something like this
>field1 := ''
>field2 := ''
>field3 := ''
>linein := 'data1,data2,data3'
>field1 := 'data1'
>field2 := ''
>field3 := ''
>linein := 'data2,data3'
>Once you have your line broke down, write to your db and read the next
>line.
>Be sure to clear all the vars before each loop or your data will be wrong.
>I have some code if you need it.
>Hope this helps.
>>All I am trying to do is take a comma-separated Ascii file and convert it
>>into an Ascii or Paradox table.  The commas serve as field separators and
>a
>>line-feed character serves as a record terminator.  There are no carriage
>>return characters in the file.

Re:Need Help making Ascii File into Table!


I rather declare a global memory alloc. And start reading until i found the
end of line. I process all delimiters and make a scan if the file is fixed.
In that way you can import large lines in a 16 bit app... :)

Regards,

Ronald

Re:Need Help making Ascii File into Table!


Re:Need Help making Ascii File into Table!


Brian.  Check your Delphi 2 CD-ROM for technical articles in the Delphi 2
sections.  I forget which directory.  There is a technical article that
describes the process you are interested in for exporting/importing
ASCII/comma delimited fields.

Regards, -= Lou Rizzuto =-
RINI
j...@mhv.net  (Remove hyphen.)

Ral Surez <rasua...@spin.com.mx> wrote in article
<33b896a9.2721...@news.spin.com.mx>...

Quote
> On 27 Jun 1997 04:02:03 GMT, "Brian Weith" <bwe...@mcs.com> wrote:

> >All I am trying to do is take a comma-separated Ascii file and convert
it
> >into an Ascii or Paradox table.  The commas serve as field separators
and a
> >line-feed character serves as a record terminator.  There are no
carriage
> >return characters in the file.

> >Reading the file byte-by-byte is out of the question because the size of
> >the file (sometimes 50MB) causes this to take way too long.

> You can read in a full buffer of say 32K or 64K (or whatever you
> like), then parse in memory. Reading will take far less than reading
> byte by byte.

> Desde la ciudad de Mexico (and willing to relocate to Canada)
> Raul Suarez

Other Threads