king1980
27th January 2010, 12:16
Hi ,

I am trying to read a csv file using following code,but when i am displaying the data using messge it's dispalying first char for first column and second column it's displaying data properly.

function readfile()
{
#define SCANS "%s,%s"
#define FIELDS a,b
long fp
string FIELDS(50)
string buffer(80)
fp = seq.open("/tmp/fl.csv", "r")
while not seq.gets(buffer,1024,fp)
string.scan(buffer,SCANS,FIELDS)
message("%s,%s",FIELDS)
endwhile
e = seq.close(fp)
}

e.g

ABC,XYZ

so it's printing A,XYZ


Regards
King1980

ashishj
27th January 2010, 12:50
Please check the declaration part of variable a and b.
Post declaration section of your program.

_Ralph_
27th January 2010, 13:45
I did not understand exactly your problem.

But try to format the string you want to show using sprintf$() before Message()

ulrich.fuchs
27th January 2010, 18:22
This here

#define FIELDS a,b
string FIELDS(50)

Defines a as a one-char string and b as a 50 char string, since the preprocesser transforms it to

string a, b(50)

Handle #defines with care - Avoiding them might help increase code readability

Uli