4 Jun 2014

How To Read Csv file in Ax 2012


//To Read Csv  file in Ax 2012

How to read CSV file in AX
    #file
    CommaTextIo       commaTextIo;    
    fileiopermission     permission;
    container              c;
    int                        x;
    int                        cols;

    permission = new fileiopermission('c:\\test.csv',#io_read);
    permission.assert();

    // specify the source file name ie. "test.csv"
    commaTextIo = new CommaTextIo('c:\\test.csv','r');
    c = commaTextIo.read();

    while(c)
    {
        cols = conlen(c);
        for(x = 1; x <= cols; x++)
        {
              info (any2str(conpeek(c,x)));
        }
        c = commaTextIo.read();
   }

   commaTextIo = null;

No comments:

Post a Comment