Have a Question?
Print

00660: Demo program to read data from a Comma Delimited ASCII file and write the records into a BBx MKEYED file

Title:

Demo program to read data from a Comma Delimited ASCII file and write the records into a BBx MKEYED file

Description:

Here’s a quick program that reads data from a Comma Separated Value file and writes the records into a BBx, MKEYED file. 

0010 OPEN (1)”ascii.csv” 
0020 LET COUNT=0 
0030 READ (1,END=0100)A$ 
0040 IF LEN(A$)>2 THEN LET COUNT=COUNT+1; EXECUTE STR(10000+COUNT)+” data “+A$ 
0050 GOTO 0030 
0100 REM 100 ================================= 
0110 CLOSE (1) 
0120 LET F$=DSK(“”)+DIR(“”)+”mkeyed” 
0130 ERASE F$,ERR=0140 
0140 MKEYED F$,[1:1:2],0,50 
0150 OPEN (1)F$ 
0160 FOR I=1 TO COUNT 
0170 DREAD NUMBER,NAME$,AGE 
0180 WRITE (1)NUMBER,NAME$,AGE 
0190 PRINT “Adding “,NAME$,” to mkeyed file” 
0200 NEXT I 
0210 END 

The ASCII.CSV file contains the following: 
1,”Brown, Sally”,30 
2,”Brown, Charlie”,32 
3,”Van Pelt, Lucy”,32 
4,”Van Pelt, Linus”,31 

When run, the program outputs: 
Adding Brown, Sally to mkeyed file 
Adding Brown, Charlie to mkeyed file 
Adding Van Pelt, Lucy to mkeyed file 
Adding Van Pelt, Linus to mkeyed file 

After the program has run, the following lines were added via the EXECUTE statement in line 40: 
10001 DATA 1,”Brown, Sally”,30 
10002 DATA 2,”Brown, Charlie”,32 
10003 DATA 3,”Van Pelt, Lucy”,32 
10004 DATA 4,”Van Pelt, Linus”,31 

The file MKEYED now contains the information from the csv file, and can be viewed with _BROWSE for verification.



Last Modified: 06/15/2000 Product: PRO/5 Operating System: All platforms

BASIS structures five components of their technology into the BBx Generations.

Table of Contents
Scroll to Top