norwim
10th July 2002, 11:26
Hi there,
I have a csv-file with 19 fields, seperated by ";".
What I try to do (and in fact did succesfully quite often) is to read this file and grab the fields with string.scan.
so I have string buf(512)
string d1(40)
string d3(40)
string d4(40)
string d6(40)
string d7(40)
string d8(40)
string d9(40)
string d10(40)
string d11(40)
string d12(40)
string d15(40)
string d18(40)
string d19(40)
plus the variables I actually need.
I read the file (seq.gets) into buf line by line.
When I do a
oki=string.scan(buf,"%s;%s;%s;%s;%s;s%;s%;s%;s%;s%;s%;s%;s%;s%;s%;s%;s%;
%s;%s",d1,mycuno,d3,d4,bbn,d6,d7,d8,d9,d10,d11,d12,telp,tefx,d15,fovn,bbnp,d18,d
19)
oki=6 and in fact d6 contains 40 byte including the ";" (seperator).
All other variables are empty.
buf contains about 300 bytes and I can see all the fields in debug mode(in buf). There is no CR or suchlike in buf.
I counted and recounted - the file should contain 19 fields, the mask for string.scan contains 19 "%s;"
Anyone any idea??
thanks in advance
Norbert
I have a csv-file with 19 fields, seperated by ";".
What I try to do (and in fact did succesfully quite often) is to read this file and grab the fields with string.scan.
so I have string buf(512)
string d1(40)
string d3(40)
string d4(40)
string d6(40)
string d7(40)
string d8(40)
string d9(40)
string d10(40)
string d11(40)
string d12(40)
string d15(40)
string d18(40)
string d19(40)
plus the variables I actually need.
I read the file (seq.gets) into buf line by line.
When I do a
oki=string.scan(buf,"%s;%s;%s;%s;%s;s%;s%;s%;s%;s%;s%;s%;s%;s%;s%;s%;s%;
%s;%s",d1,mycuno,d3,d4,bbn,d6,d7,d8,d9,d10,d11,d12,telp,tefx,d15,fovn,bbnp,d18,d
19)
oki=6 and in fact d6 contains 40 byte including the ";" (seperator).
All other variables are empty.
buf contains about 300 bytes and I can see all the fields in debug mode(in buf). There is no CR or suchlike in buf.
I counted and recounted - the file should contain 19 fields, the mask for string.scan contains 19 "%s;"
Anyone any idea??
thanks in advance
Norbert