AX 2012: Read CSV File using X++

public void readCsvFile(){
#File
Io io;
container recordCon;
boolean firstLine = true;

FilePath processfilePath = @’C:\Temp\test.csv’;

io = new CommaTextIo(processfilePath, #IO_Read);

if(!io || io.status() != IO_Status::Ok){
throw error(“@SYS19358”);}

while (io.status() == IO_Status::Ok){
recordCon = io.read();
if (recordCon){
if (firstLine){
firstLine = false;} // To skip headeror the firstline
else{
// Do something here…}}}}

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