I have a tree structure in a .csv file (nodes are of type text), and after reading the csv i want to store the data in a ruby object. I went through a few tree plugins and i think nested_set would serve the purpose for me.
However, i am facing problem with fixing a format of csv file, so that i can read it and convert into tree object. Is there any direct way of converting a csv file or 2 dimensional array, into a tree data structure??
I have a tree structure in a .csv file (nodes are of type text),
Share
After you clarified that you don’t need to store this tree in database, I suggest to throw away NestedSets (they’re to store nested sets of objects on RDBMS, which you don’t need). What you need i simple tree
As I have right to choose format of CSV file, then I suggest sth like this:
Tree root is first row, without parent, and there is always order that parent is declared before its children. That way you can build tree
If you need to get all texts from subnodes, then you need to use more tricks