Saving array data to a file (.dat, .txt, access or excel)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Warlop3
    New Member
    • Nov 2006
    • 1

    Saving array data to a file (.dat, .txt, access or excel)

    Hi first time so bear with me, I have a program that records the split and length times of swimmers, upto 8 lanes and upto a distance of what ever i create the array the program works really well and still under development, but am struggling with a way to save the data for obvious future analysis, I am quite willing to send the code if you can help.

    Thanks
    Warlop3
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Originally posted by Warlop3
    Hi first time so bear with me, I have a program that records the split and length times of swimmers, upto 8 lanes and upto a distance of what ever i create the array the program works really well and still under development, but am struggling with a way to save the data for obvious future analysis, I am quite willing to send the code if you can help.

    Thanks
    Warlop3
    Hi. Post the code please or email it to me if you prefer.

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Originally posted by willakawill
      Hi. Post the code please or email it to me if you prefer.
      (Sorry willakawill, just can't help myself... :))

      I do have some thoughts on this one, as I've just been doing something similar. One method (certainly not the only one, and not necessarily the best) is to open your data file in binary mode and simply PUT the array. Then you can GET it later.

      I recommend storing additional information which may be required when reading it back, such as the dimensions of the array. Very simple example...

      To save
      Code:
      Open "MyFile.dat" For Binary Access Write Lock Write As #1
      Put #1, , ArraySize
      Put #1, , MyArray()
      Close #1
      To read back
      Code:
      Open "MyFile.dat" For Binary Access Read Shared As #1
      Get #1, , ArraySize
      ReDim MyArray(1 To ArraySize) ' May be unnecessary? Can't remember.
      Get #1, , MyArray()
      Close #1
      Something else I recommend to everyone is to store something human-readable in your data files, preferably either at the very start or the very end, which visually identifies what the file is for. In other words, when you come across some data file ten years later and wonder why it exists and whether it might have been important, it is very nice to be able to look inside it and see something indicating what it's about. For example, you could have something at the start which indicates "Data file for swimming statistics thingy, version 1.5".

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        I have split gunw's message off to its own thread.

        Comment

        Working...