How do you open and parse a csv file in dynamics ax?
Reading a comma separated values (csv) file in dynamics ax
static void TestCommaTextIO(Args _args)
{
#File
CommaTextIo commaTextIo;
FileIOPermission permission;
container containFromRead;
int x;
int cols;
;
permission = new FileIOPermission('c:\\junk\\mycsv.csv',#io_read);
permission.assert();
commaTextIo = new CommaTextIO('c:\\junk\\mycsv.csv','R');
containFromRead = commaTextIo.read();
While(containFromRead)
{
cols = conLen(containFromRead);
for(x=1;x<=cols;x++)
{
print conpeek(containFromRead,x);
}
containFromRead = commaTextIo.read();
}
pause;
commaTextIo = null;
}
@Garrulity would it be safe to do both? –
Flanders
it's good question. i think
While( commaTextIo.status == IO_Status::Ok )
is safe anyway. I think While(containFromRead)
is not safe if csv contains empty line as regular data. Fixed –
Garrulity © 2022 - 2024 — McMap. All rights reserved.
while( commaTextIo.status == IO_Status::Ok )
of course. The codeWhile(containFromRead)
is readinguntil first empty line
. – Garrulity