Use "%s@,%f..." to specify (with @) that the string should stop at the first comma. On Tue, Oct 8, 2013 at 5:28 AM, Robert Roessler wrote: > Francois Berenger wrote: > >> This example line and scanning format work: >> >> # let line = "active_ZINC01535869 >> 0.470,0.389,0.479,0.453,0.470,**0.631,0.562,0.590,0.677,0.558,**0.379";; >> val line : string = >> "active_ZINC01535869 >> 0.470,0.389,0.479,0.453,0.470,**0.631,0.562,0.590,0.677,0.558,**0.379" >> # Scanf.sscanf line "%s %f,%f,%f,%f,%f,%f,%f,%f,%f,%f,**%f" (fun name s1 >> s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 -> (name, s1, s2, s3, s4, s5, s6, s7, >> s8, s9, s10, s11));; >> - : string * float * float * float * float * float * float * float * >> float * float * float * float >> = >> ("active_ZINC01535869", 0.47, 0.389, 0.479, 0.453, 0.47, 0.631, 0.562, >> 0.59, 0.677, 0.558, 0.379) >> >> This one doesn't: >> >> # let line = >> "active_ZINC01535869,0.470,0.**389,0.479,0.453,0.470,0.631,0.** >> 562,0.590,0.677,0.558,0.379";; >> val line : >> string = >> >> "active_ZINC01535869,0.470,0.**389,0.479,0.453,0.470,0.631,0.** >> 562,0.590,0.677,0.558,0.379" >> >> # Scanf.sscanf line "%s,%f,%f,%f,%f,%f,%f,%f,%f,%**f,%f,%f" (fun name s1 >> s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 -> (name, s1, s2, s3, s4, s5, s6, s7, >> s8, s9, s10, s11));; >> Exception: End_of_file. >> >> I am quite surprised. >> I was expecting the first separator being a space or a coma >> to behave the same. >> > > The specification of scanf "%s" is "Any number of non-whitespace > characters, stopping at the first whitespace character found". > > So, perhaps not that surprising? > > Regards, > -- > Robert Roessler > > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/**arc/caml-list > Beginner's list: http://groups.yahoo.com/group/**ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-**bugs >