Results 1 to 4 of 4
  1. #1
    trl
    trl is offline Member
    Join Date
    May 2011
    Posts
    6
    Rep Power
    0

    Default Suggestions on approach for retrieving data from text file

    Hello,

    I have dozens of .txt files I need to do various statistical analysis on. All files are formatted the same way with each data field in the same position in all files. I plan to create an ArrayList of object files with each having the same attributes and perform the analysis once they’ve been read. My question is what is the best way of reading the data of such a file? Random access or sequentially? I’ve ran into problems both ways. Or some other method?

    This is a personal project and not any type of school assignment.

    Below is an example of part of a file. I would begin reading at 89, then 25.8 and so on.

    Thanks in advance for any help.

    Tom



    Uploaded with ImageShack.us

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    From your description it sounds like you could use a BufferedReader and read the data a line at a time (splitting on the spaces to obtain the values that constitute the state of one of your objects). If you have run into problems with such a (sequential) approach, what are they?

  3. #3
    trl
    trl is offline Member
    Join Date
    May 2011
    Posts
    6
    Rep Power
    0

    Default

    I tried to split on the spaces and it didn't work. It's been a while but I think it was a nullpointerexception. Just to troubleshoot, I created a file with just a few values that were comma seperated and split on the comma and that worked fine. Of course it only had a couple of lines and the read point was at the beginning of the file. That was the problem with random access. The files are all very similar in size but they do very slightly; < 100 bytes. That seems to make the seek pointer get stuff it's not supposed to.

    I'm a very average programmer and if there were only a few files I would do the analysis by hand. But there's a bunch of 'em.

    Thanks for your suggestion.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by trl View Post
    I tried to split on the spaces and it didn't work. It's been a while but I think it was a nullpointerexception.
    I'll bet that with some intense and clever debugging you can figure out why your code isn't working. If not, please share your code, the data file, and your error messages with us.

Similar Threads

  1. Replies: 2
    Last Post: 03-25-2011, 02:36 PM
  2. Replies: 6
    Last Post: 12-01-2010, 05:31 AM
  3. Retrieving the data posted to a JSP file from HTML file
    By marie in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 10-21-2010, 08:37 AM
  4. Replies: 3
    Last Post: 06-02-2010, 06:58 PM
  5. error while retrieving data from data base
    By kirtesh4u in forum New To Java
    Replies: 5
    Last Post: 11-15-2008, 04:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •