2

What are some common formats for writing 3d data arrays to (txt) file?

(if I have to do this, I would rather use a format that someone else can follow)

FrustratedWithFormsDesigner
  • 26,726
  • 31
  • 139
  • 202
Connor Albright
  • 723
  • 4
  • 13
  • 29

2 Answers2

2

I don't know of a pre-existing standard for something like this, but how about:

[
  [
    [1,2,3],
    [4,5,6]
  ],
  [
    [7,8,9],
    [10,11,12]
  ]
],
[
  [
    [1,2,3],
    [4,5,6]
  ],
  [
    [7,8,9],
    [10,11,12]
  ]
]

It's easy to read but if you want to flatten it it would look like this:

[ [ [1,2,3], [4,5,6] ], [ [7,8,9], [10,11,12] ] ], [ [ [1,2,3], [4,5,6] ], [ [7,8,9], [10,11,12] ] ]

FrustratedWithFormsDesigner
  • 26,726
  • 31
  • 139
  • 202
1

Google doesn't come up with a standard format, however here is a tutorial:

http://ww.functionx.com/csharp/Lesson23.htm

it uses something that could be reduced to the following:

double[2, 3, 5]:
[
        [
            [  12.44, 525.38,  -6.28,  2448.32, 632.04 ],
            [-378.05,  48.14, 634.18,   762.48,  83.02 ],
            [  64.92,  -7.44,  86.74,  -534.60, 386.73 ]
        ],
        [
            [  48.02, 120.44,   38.62,  526.82, 1704.62 ],
            [  56.85, 105.48,  363.31,  172.62,  128.48 ],
            [  906.68, 47.12, -166.07, 4444.26,  408.62 ]
        ]
]

Correct me if I am wrong but basically you would just create an array of arrays to accomodate however many dimensions you need.

amarcy
  • 1,485
  • 2
  • 19
  • 28
  • Well, if both you and @FrustratedWithFormsDes came up with the same thing it is probably worthwhile. It still seems a little clunky to me, but I cant think of anything else. – Connor Albright Nov 18 '10 at 15:36