Reading and Writing DataFrames that contain ComponentArrays

MTKHelpers supports setting parameters that are symbolic arrays, by specifying them as ComponentVector.

Therefore, it is often useful to store parameters as ComponentVector in one columns of a DataFrame. A DataFrame with such a columns, however, is not easily written and retrieved from a interoperable file, such as CSV.

The following functions write and read data of such a DataFrame in CSV format that can be read by other tools. By using additional information on the Axes stored in comments, the ComponentVectors can be reconstructed.

MTKHelpers.write_csv_cvFunction
write_csv_cv(con::IO, df0::DataFrame)
read_csv_cv(con::IO)::DataFrame

Write/Read a DataFrame that contains columns of type ComponentArrays to a CSV file. Each ComponentArray column is replaced by length(cv) columns, and information on the axis is generated as a comment in front of the CSV.

When re-reading the CSV, the respective ComponentArrays are recreated usingn this information and are replaced for the read plain columns.

Make sure to not duplicate names. If there is a ComponentArray column u0 containing three Floats, the following three columns are added (and should not exist before): u0_1, u0_2, u0_3.

source