fileserializationfilestructure

writing a 3d array of data to file


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)


Solution

  • 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] ] ]