Hello all,
I got a csv-file from a foreign system and natural seems to read wrong values out of it. OK, I got a workaround for it. But I didn’t expect that behaviour.
Reproduceable sample :
define data local
1 #tab (A1/1:7)
end-define
define work file 1 '/tmp/test.csv' /* type 'csv'
write work file 1 variable 'A' 'B' 'C' 'D' 'E' 'F'
write work file 1 variable '1' '2' '3'
write work file 1 variable 'z' 'y' 'x' 'w'
write work file 1 variable 'a' 'b' 'c'
close work file 1
read work file 1 #tab(*)
write #tab(*)
end-work
end
Output:
A B C D E F
1 2 3 D E F
z y x w E F
a b c w E F
… a trap for the unwary. Since there is no “read work … variable” my workaround is:
read work file 1 #TAB(*) giving length #csvfields
if #csvfields < *UBOUND(#TAB)
add 1 to #csvfields
reset #tab(#csvfields:7)
end-if
Regards
matthias