Results 1 to 3 of 3

Thread: Reading Text Files for Graphing

  1. #1
    Join Date
    Jun 2011
    Posts
    203
    Thanks
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Reading Text Files for Graphing

    I'm writing a basic program which will open a text file, read the data and plot it. The text files will have several formats of data i.e. one format will be something like this:

    124 | 678 | 7890
    4567 | 27487 | 5678

    with varying numbers of rows and columns, and another text file will just have spaces separating the values

    124 678 7890
    4567 27487 5678

    Firstly, how do I discern between values in a particular row? There's readLine() which will enable me to go down a list of values as I please but how do I go about specifying separation between values?

    Secondly, in some cases, I'll be processing the data before plotting/graphing it. i.e. I might need to do basic mathematical operations on the values prior to spitting out final results, what would be the best method of working with potentially large volumes of data (not massive to the extent of gigabytes but possibly 20 megs or so although that's a guess). I mean, what would be an efficient way of working with it, simply use arrays? The operations will all be between values in the same row, so that simplifies it somewhat i.e. I won't be potentially accessing row 20 column 5 and multiplying it by row 1 column 239. Although I'll probably need to sort selected columns of the text document.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Reading Text Files for Graphing

    Try QString::split() and QRegExp (if required).

    How you need to work with large volumes, 20MB of numbers expressed in ASCII is not that big, will depend on exactly what you need to do. If you need random access to cells then you have a different set of problems to those faced if you need to sort the entire file based on a column, column or a derived value.

  3. #3
    Join Date
    Jun 2011
    Posts
    203
    Thanks
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Reading Text Files for Graphing

    Thanks for the response. Just trying to sort the data, then plot the results. The sorting is done for a reason that's long to explain for my intended application but suffice to say the calculations are really basic, although as I write this I'm starting to see some difficulties that I didn't anticipate originally.

Similar Threads

  1. Access violation when reading big text files
    By robertson1 in forum General Programming
    Replies: 0
    Last Post: 18th September 2008, 06:59
  2. Reading files in C++
    By maverick_pol in forum General Programming
    Replies: 2
    Last Post: 15th May 2008, 08:53
  3. problem with reading text files
    By Axsis in forum Newbie
    Replies: 1
    Last Post: 25th April 2008, 12:29
  4. reading files
    By baray98 in forum Newbie
    Replies: 2
    Last Post: 20th September 2007, 12:31
  5. how to save sequences of text files and sound files
    By nagpalma in forum Qt Programming
    Replies: 8
    Last Post: 3rd July 2007, 00:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.