Automating tree view creation through csv file import

2,642 views
Skip to first unread message

Vitte Thibaut

unread,
Feb 7, 2017, 2:45:59 PM2/7/17
to draw.io
Hi,

Dear draw.io users,

I have a table in excel with a hierachy. It's a energy meters infrastructure definition for a building.
It looks like this :

ID    /    parent ID    /    fluid   /   sub-building     / commentary
1     /                       /   water  /  kitchen              / blablabla
2    /           1          /   water   / dishwasher        / blablabla
3    /                      /     gas    /  main                  / dsmlkfm
4   /         3           /  gas       /   heat unit           / dlkjfslkd
5  /    4                /   gas       /   boiler               / clkjklsdjklfj
6 /    4                /    gas      /  domestic HW    / lkjcldjsljkc
And so on. I have like 50-100 meters.

I would like to automate the creation of a tree diagramm following that parent/child structure. Is-it possible to do it in draw.io ? Or do you have any idea ?
I can't do it manually with creating each form, that would kill me!
The tree diagramm should looks like :

       1                      3
       |                        |
        2                      4
                              |     |
                              5    6

With the numbers replaced with the attributes of each meter.

Thanks in advance !

Thibaut

  

Gaudenz Alder

unread,
Feb 7, 2017, 3:00:47 PM2/7/17
to dra...@googlegroups.com
Have a look at the example in File, Import from, CSV. The system tries to find a (single) root for automatic tree layout, if there are multiple roots you can run the layout manually by selecting each root and clicking Arrange, Layout, Vertical Tree. The import dialog contains the configuration section (with #), which holds the node label (with references to column names), definitions for the connections to be created (essentially the source and target column name, Parent ID and ID in your case, in JSON format) and other things. The CSV data can be pasted below the configuration section, with the first line containing the column names.

Vitte Thibaut

unread,
Feb 7, 2017, 3:25:25 PM2/7/17
to draw.io
Oh Alder, thank you , thank you, thank you !

I've been using draw.io for one year, doing diagramm for multuple purpose, and never seen this functionnality!
I've passed many hours on google, even tried to play with some R script...

@ draw.io team : You should communicate on that! There are several questions on stack or Quora on this topic and everybody uses some code, with some very poor solutions.

Thanks again.

David Benson

unread,
Feb 7, 2017, 3:26:40 PM2/7/17
to draw.io

Vitte Thibaut

unread,
Feb 7, 2017, 3:37:26 PM2/7/17
to draw.io
On Google+, seriously? That thing still exists ?

Vitte Thibaut

unread,
Feb 7, 2017, 3:39:51 PM2/7/17
to draw.io
(It was a joke) (I went to their twitter, and it's on it.)
I understand why I wasn't aware as it's 7 days old!

David Benson

unread,
Feb 7, 2017, 3:40:40 PM2/7/17
to draw.io
draw.io is a free, open source project run by 2 people (guess which 2). You're welcome to help spread the message :).

Gaudenz Alder

unread,
Feb 7, 2017, 4:11:45 PM2/7/17
to draw.io
Yes, CSV import is new. I guess you'd have looked for it in the import menu? Let us know if anything is missing. We use Twitter, Facebook and Google+ to announce new features. Where are those stack and quora questions?

Vitte Thibaut

unread,
Feb 8, 2017, 3:04:41 AM2/8/17
to draw.io
I did'nt bookmarked the questions, sorry.
At least there's mine on stackoverflow :

Vitte Thibaut

unread,
Feb 8, 2017, 2:36:40 PM2/8/17
to draw.io
There's a bug in the relationship definition :

It doesn't work (Nodes are created, but not linked) with the name (defined by the column names of the table) "ID" for child and "parentID" for parent when it works when changed with the names NID and PID respectively.
The rest of the text import is identical.

Oh boy I've spent time finding why it did'nt work !

++

Gaudenz Alder

unread,
Feb 9, 2017, 2:52:04 AM2/9/17
to draw.io
Thanks for the feedback! Ignored data was removed _before_ processing the source column names. This will be fixed in the next release.
Reply all
Reply to author
Forward
0 new messages