Loading ...
Sorry, an error occurred while loading the content.

9681Re: "ocaml_beginners"::[] Writing to many files

Expand Messages
  • Johann Spies
    Apr 22, 2008
    • 0 Attachment
      On Fri, Mar 28, 2008 at 07:24:52AM -0600, William D. Neumann wrote:
      > 2: If you have too many files to keep open, or if you have really long runs
      > of the same date in your data, you can just coche the last date and channel
      > in outputfile.
      >

      I have adapted your code because I want to use two different output
      files. My code produces an error which I do not understand:

      Characters 226-250:
      This pattern matches values of type 'a option * 'b option * 'c option
      but is here used to match values of type 'd option * 'e option

      The code:


      let last_date = ref None
      and last_auth = ref None
      and last_acc = ref None

      let outputfile date =
      match !last_date,!last_auth, !last_acc with
      | Some d, Some oc when d = date, Some ot -> oc,ot
      | Some d, None when d = date, None ->
      failwith "Yipes! Cached date but no cached channel!"
      | Some d, Some oc, Some ot ->
      close_out oc;
      close_out ot;
      let new_oc = open_out_gen
      [Open_creat;Open_append;Open_wronly]
      0o644
      ( date ^ "_acc.csv" ) in
      let new_ot = open_out_gen
      [Open_creat;Open_append;Open_wronly]
      0o644
      ( date ^ "_auth.csv")
      in
      last_date := Some date;
      last_acc := Some new_oc;
      last_auth := Some new_ot;
      new_oc, new_ot
      | None,None,_ ->
      let new_oc = open_out_gen
      [Open_creat;Open_append;Open_wronly]
      0o644
      ( date ^ "_acc.csv" ) in
      let new_ot = open_out_gen
      [Open_creat;Open_append;Open_wronly]
      0o644
      ( date ^ "_auth.csv")
      in
      last_date := Some date;
      last_acc := Some new_oc;
      last_auth := Some new_ot;
      new_oc, new_ot

      | _ ->
      (* None for date, some open channel -- should never hapen *)
      assert false


      Can somebody enlighten me on this one please?

      Regards
      Johann
      --
      Johann Spies Telefoon: 021-808 4036
      Informasietegnologie, Universiteit van Stellenbosch

      "If my people, which are called by my name, shall
      humble themselves, and pray, and seek my face, and
      turn from their wicked ways; then will I hear from
      heaven, and will forgive their sin, and will heal
      their land." II Chronicles 7:14
    • Show all 17 messages in this topic