let sum_second_col text = let lines = String.split_on_char '\n' text in List.fold_left (fun acc line -> let fields = String.split_on_char ',' line in if List.length fields >= 2 then acc + int_of_string (List.nth fields 1) else acc ) 0 lines ;; sum_second_col "a,1,extra\nb,2,extra\nc,3,extra\nd,4,extra"