TableDataFrom_File

static void TableDataFrom_File(Args _args)

{

commaIO commaIO;

container readLine;

Tab2 k;

FileIOPermission fio;

FileName nameOfTheFile = “c:\anil.txt”; //csv

;

if (winapi::fileExists(nameOfTheFile) == false)

throw error(strfmt(“file %1 not found”, nameOfTheFile) );

fio = new FileIOPermission(nameOfTheFile, ‘r’);

// read – r, write – w, append – a

fio.assert(); // demand

commaIO = new commaIO(nameOfTheFile,’r’);

commaIO.inFieldDelimiter(‘,’); // t – tab, | // outFieldDelimiter commaIo.inRecordDelimiter(‘rn’); // OutRecorDelimiter – read line by line

ttsbegin;

if(commaIO)

{

while(commaIO.status() == IO_status::Ok)

{

readLine = commaIO.read(); //writeExp

if (conlen(readLine) > 1) // check whether there are values in the next line {

k.Address = conpeek(readLine,1); k.DName = conpeek(readLine, 2); k.insert();

}

}

}

ttscommit;

CodeAccessPermission::revertAssert();

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: