Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Data Export

1 view
Skip to first unread message

Dorian C. Chalom

unread,
Aug 12, 2009, 9:45:26 PM8/12/09
to
I need to export some data in GW Basic Data files to text files. What is
the best way to do that?


Tom Lake

unread,
Aug 12, 2009, 11:07:08 PM8/12/09
to

"Dorian C. Chalom" <DCh...@Comcast.net> wrote in message
news:Od#0Ef7GK...@TK2MSFTNGP05.phx.gbl...

> I need to export some data in GW Basic Data files to text files. What is
> the best way to do that?
>

If they're sequential (open for output) files, you don't have to do
anything.
They're already readable. If they're random or relative files
use a GW-BASIC program to read them in and PRINT them to a sequential file.
It will help greatly to know what FIELD statement was used to create them.
If you don't it will take more work but it's not impossible.

Tom Lake

Dorian C. Chalom

unread,
Aug 13, 2009, 12:03:49 AM8/13/09
to
When I look at the DAT files with a text editor I see all kinds of control
characters in the files. How do I just get the data out of the fies
cleanly?

Thank you

"Tom Lake" <toml_...@hotmail.com> wrote in message
news:5B4B06F4-D274-49BB...@microsoft.com...

rebel

unread,
Aug 13, 2009, 2:04:58 AM8/13/09
to
On Thu, 13 Aug 2009 00:03:49 -0400, "Dorian C. Chalom" <DCh...@Comcast.net>
wrote:

>When I look at the DAT files with a text editor I see all kinds of control
>characters in the files. How do I just get the data out of the fies
>cleanly?

As Tom pointed out, a sequential file written by GW (or Q)Basic is a simple falt
ascii file without the formatting crud that word-porcessors often add. If there
are any characters other than the actual data or CR/LF in there, it is
part_of_the_data that was written. The problem boils down to either writing
some lines of code to parse the files you have, or fix the source that is
creating these files.

Can you give us an example of what you are seeing - preferably with a hex editor
so we can see the actual "codes"?

Todd Vargo

unread,
Aug 13, 2009, 1:58:59 PM8/13/09
to

The control characters could be data stored in bit form. If by "get the data
out of the files cleanly", you mean to just remove all non-alpha-numeric
characters, that can be done easily with the following code. If you want to
also remove all CR and LF characters, then remove the "10, 13," from the
CASE line. If you want anything cleaner than that, then you will have to
provide the program code that created the data file and/or provide the data
file.

OPEN "MyData.dat" FOR BINARY AS #1
OPEN "Output.txt" FOR OUTPUT AS #2
in$ = " "
FOR i = 1 TO LOF(1)
GET #1, i, in$
SELECT CASE ASC(in$)
CASE 32 TO 126
ii = ii + 1
PRINT #2, in$;
END SELECT
NEXT i
CLOSE

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

Todd Vargo

unread,
Aug 13, 2009, 11:51:15 PM8/13/09
to
Dorian C. Chalom wrote:
> I believe the files may be Random Access.
> Could someone please provide a sample of the code to read in the file and
> write it out to a sequential file?
>
> I attached a copy of one of the files.

Records appear to be 300 characters in length. This will insert CRLF every
300 characters in the output file so you can identify field lengths.

OPEN "supplier.dat" FOR BINARY AS #1


OPEN "Output.txt" FOR OUTPUT AS #2

in$ = SPACE$(300)
FOR i = 1 TO LOF(1) STEP 300
GET #1, i, in$
PRINT #2, in$; CHR$(13); CHR$(10);

Dorian C. Chalom

unread,
Aug 14, 2009, 9:47:30 AM8/14/09
to
Todd;

Thank you very much.
How did you determine the record length I have 2 or three more files I must
do the same with.


"Todd Vargo" <tlv...@sbcglobal.netz> wrote in message
news:%23faB5JJ...@TK2MSFTNGP02.phx.gbl...

Todd Vargo

unread,
Aug 14, 2009, 4:27:43 PM8/14/09
to
Dorian C. Chalom wrote:
> Todd;
>
> Thank you very much.
> How did you determine the record length I have 2 or three more files I
must
> do the same with.

Deductive reasoning. I looked at the file for a pattern and then counted the
number of characters. Luckily, there was no header to skip over. If you
change the names in the code and try it on the other files you might get
lucky.

0 new messages