Skip to content
Aaron Niyonzima edited this page Feb 18, 2023 · 3 revisions

Working with Files

Reading text file

Reading text files(txt, csv, etc) in info basic is done in 3 steps:

  1. Open file using OPENSEQ
  2. Read file (one line at time) using READSEQ
  3. Close file using CLOSESEQ

Let's write a simple program to read a csv file

PROGRAM MTD.ReadFile
   
    dir = '../bnk.interface/EBANK.IN'
    filename = 'transaction.csv'

    OPENSEQ dir, filename TO ptr THEN
        LOOP
            READSEQ line FROM ptr ELSE BREAK
            CRT line
        REPEAT
    END ELSE CRT 'Failed to open ': filename
    
    CLOSESEQ ptr

END
Clone this wiki locally