Reading in data from file in certain format
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Reading in data from file in certain format

  1. #1
    Join Date
    Nov 2012
    Posts
    2

    Reading in data from file in certain format

    I have a multivalued function (created in some other software Mathematica) that looks like f[8.7,5.4]=4.8+8.7*I. In other words it's a complex valued function of two variables. I store the output of this function over a range of parameters in a text file that looks like:

    Code:
           f[1,2]=9.8+8.7I;
           f[4,5]=5.6-5.21I;
           . 
           .
    I could store it differently if that is easier, but essentially I just want some c++ code to read this in and store it, either in a vector type structure or Dictionary? (I don't think a double array will work as I don't know how long list of data is in advance).

    Could anyone help toward this? thanks

  2. #2
    Join Date
    Jan 2009
    Posts
    1,689

    Re: Reading in data from file in certain format

    I never ever recommend writing your own file format, put it in text format and use XML, JSON, YAML, INI... These formats exist for a reason

  3. #3
    Join Date
    Nov 2012
    Posts
    2

    Re: Reading in data from file in certain format

    XML is fine with me, could you give me some pointers on how to do this? should the input file look like say

    Code:
    <param1>8</param1> <param2>9</param2>  <value>2.5+8.9*I </value>
    <param1>56</param1> <param2>5.6</param2>  <value>5.6+4.9*I </value>
    then if this is correct how do I read this in, and what would be the best object to store the data in?

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center