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(‘\r\n’); // 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();
}
No comments:
Post a Comment