in reply to How to write complete hash into CSV?
Hello CSharma. CSV data is flat, so there is no straightforward way to represent nested structures. You can still come up with a representation for your structure (eg: database-like representation with several tables and indexes from one table to another), but you'll have to define it first so that we can understand what you're doing. To do that, please write a simple example, a structure with dummy (but short) data and what you except to find in your CSV. I haven't tried to understand your current structure because of how long it is.
The code you have provided does not check anywhere if all attributes defined in one element are the same in the following, this may be the case, but you have to be sure about it to avoid some values being shifted left or right. If the members of the elements you need to represent are fixed, or you know the list of attributes beforehand, you can iterate over a fixed list of keys, in the other case another strategy might be required (like writing each new attribute at the end of table).
|
|---|