Inserting text qualifier when importing CSV file

Hi ,

Just wondering if someone can help me please . I am importing a CSV file in Axapta 3.0 using AsciiIO class. The problem i am facing is that some of my text include an extra comma in it like

Cust, Cust Address,City

AX001,“House 2, Green Street”,London,

can someone please tell me how can i mention a text qualifier " so it could eliminate the extra comma from address field.

my code is

static void Job115(Args _args)

{

AsciiIO AsciiIO;

Container c;

str Location;

;

location = “C:\Temp\Ebay\Sales Order\Order.csv”;

AsciiIO = new AsciiIO(location,“R”);

AsciiIO.inFieldDelimiter(’,’);

c = AsciiIo.read();

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

{

info(strfmt(“1 %1 | 2 %2 | 3 %3 | 4 %4 | 5 %5 | 6 %6 | 7 %7 |”,conpeek(c,4),conpeek(c,5),conpeek(c,6),conpeek(c,7),conpeek(c,8),conpeek(c,9),conpeek(c,10)));

c = AsciiIO.read();

}

}

Thanking you in anticipation

Hi Ayesha,

I think you need to clean the data first before start sing it . here is the code which take texts input and and return the text after removing extra commas and speech marks . you can then write this text on CSV file and then re import again . it should be fine .Tell me if there is any problem

static void Job669(Args _args)

{

str _text,note,cleanText;

int charpos,s1,s2,i,more;

int x;

char RepChar = ‘,’;

char RepCharWith = ’ ';

str text(str text)

{

s1 = strFind(text,’"’,1,strlen(text));

s2 = strFind(text,’"’,s1,strlen(text));

for (i=s1;i<s2+4;i++)

{

charpos = strScan(text,’,’,s1,s2);

text = strpoke(text,’ ',charpos);

s1 = strFind(text,’"’,1,strlen(text));

s2 = strFind(text,’"’,s1+1,strlen(text));

charpos = strScan(text,’,’,s1,s2);

if (charpos > s2)

{

break;

}

}

if (s1 || s2)

{

text = strdel(text,s1,1);

text = strdel(text,s2-1,1);

}

return text;

}

;

more = 1;

_text = ‘AXT001,“House,42,ENF”,Enfield,“U,K”’;

while( more !=0)

{

_text = text(_text);

more = strFind(_Text,’"’,1,strlen(_Text));

}

info(_text);

}

Hello , Yes it works . Many thanks for taking me out from this trouble Mr. Shaikh