≡ Menu

Reading CSV files in Dynamics Ax 2012.

Today I come across a scenario where, I have to read data from csv file.


Reading data from csv file is very easy with IO operation. For example I have csv file with following student first name and last name which I have to migrate into custom ax table.

CVS file



Custom Ax table.




Following a simple code snippet which read csv file and insert data into custom data

static void Job9(Args _args)



IO  iO;

Name FirstName;

Name LastName;

StudentInfo _StudentInfo;

FilenameOpen        filename = “c:\\StudentInfo.csv”;//To assign file name

Container           record;

boolean first = true;


    iO = new CommaTextIo(filename,#IO_Read);

if (! iO || iO.status() != IO_Status::Ok)


throw error(“@SYS19358”);


while (iO.status() == IO_Status::Ok)


record = iO.read();// To read file

if (record)


if (first)  //To skip header


first = false;





FirstName = conpeek(record, 1);//To peek record

LastName = conpeek(record, 2);


_StudentInfo.LastName =LastName;


//     info(strfmt(‘%1–%2’,custAccount,custname));







After running the ax job, I found following data into Ax table.

4-28-2015 9-59-45 PM


If you saw, first row of csv is missing in table. The reason for that above code snippet consider first row as header so it did not require to insert it.


One thing I missed, The reference, original code snippet is belongs to “Jitendra Kumar Singh”


{ 0 comments… add one }

Leave a Comment