Tuesday, November 6, 2012

Reading a comma-separated value file


class ReadCommaFile
{
}


public static client void main(Args _args)
{
    CommaTextIo file;
    container line;
    ;
    #define.filename(@'C:\Temp\accounts.csv')
    #File
    file = new CommaTextIo(#filename, #io_read);
   
    if (!file || file.status() != IO_Status::Ok)
    {
        throw error("File cannot be opened.");
    }
    line = file.read();
   
    while (file.status() == IO_Status::Ok)
    {
        info(con2Str(line, ' - '));
        line = file.read();
    }
}

No comments: