Is there a script to create a diagram from a Google Sheet holding CSV

965 views
Skip to first unread message

Michael Ellyett

unread,
Nov 2, 2021, 1:26:31 AM11/2/21
to diagrams.net Q&A
At present I create many diagrams from information held in Google Spreadsheets (which effective a set of models e.g. objects, process, etc.)

This sheets generate CSV. I think have to:
a) in Google Sheets - copy the data in the Sheet with the CSV
b) open a diagram.net diagram (which is in GDrive) or toggle to it if it is open
c) turn off autosave [because others half the time it says it is saving]
d) select everything in the diagram and delete it
e) navigate 4 levels down Arrange/Insert/Advanced/CSV
f) select every in the CSV area and delete it [this is quite frustrating the thousandth time you do it]
g) paste the CSV data copied in a) in
h) select import

Invariably then I have to change something in the model (Google Sheet) and repeat steps a/d/e/f/g/h

I would like a script that takes a data from a range in a Google Sheet and imports that data as a CSV.

M

diagrams.net Q&A

unread,
Nov 2, 2021, 1:39:44 AM11/2/21
to diagrams.net Q&A
Try creating a link with https://jgraph.github.io/drawio-tools/tools/csv.html (see note about public Google sheets).

Michael Ellyett

unread,
Nov 4, 2021, 5:51:44 PM11/4/21
to diagrams.net Q&A
I have tried that but I get this error.
image.png
Here is the 
##
## Example CSV import. Use ## for comments and # for configuration. Paste CSV below.
## The following names are reserved and should not be used (or ignored):
## id, tooltip, placeholder(s), link and label (see below)
##
#
## Node label with placeholders and HTML.
## Default is '%name_of_first_column%'.
#
# label: %name%<br><i style="color:gray;">%position%</i><br><a href="mailto:%email%">Email</a>
#
## Node style (placeholders are replaced once).
## Default is the current style for nodes.

I get this error
image.png

I can tell that it is reading the GSheet - because I can see the contents in some of the error messages (e.g. above)

If I boil the example down to just these 5 lines I get the same error as I do trying to load my data "cannot read properties of null length"
# connect: {"from": "manager", "to": "name", "invert": true, "style": "endArrow=blockThin;"}
name,position,id,location,manager,email,fill,stroke,refs,url,image
Edward Morrison,Brand Manager,emo,Office 2,Tessa Miller,m...@example.com,#d5e8d4,#82b366,,https://www.draw.io,https://cdn3.iconfinder.com/data/icons/user-avatars-1/512/users-10-3-128.png
Alison Donovan,System Admin,rdo,Office 3,Tessa Miller,m...@example.com,#d5e8d4,#82b366,"emo,tva",https://www.draw.io,https://cdn3.iconfinder.com/data/icons/user-avatars-1/512/users-2-128.png

On Tue, 2 Nov 2021 at 18:39, diagrams.net Q&A <dra...@googlegroups.com> wrote:
Try creating a link with https://jgraph.github.io/drawio-tools/tools/csv.html (see note about public Google sheets).

--
You received this message because you are subscribed to a topic in the Google Groups "diagrams.net Q&A" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/drawio/arFQYW_0SJA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to drawio+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/drawio/fc0b13e2-29fd-46e4-bc9e-e645eac60e98n%40googlegroups.com.


--
Michael Ellyett
Phone: +64 21 748 752
GTalk/Yahoo/Skype = Michael.Ellyett; AIM = MichaelEllyett

diagrams.net Q&A

unread,
Nov 5, 2021, 10:55:24 AM11/5/21
to diagrams.net Q&A
The descriptor needs to go into the text box (no leading # except for comments) and the CSV data will be served from the URL.

Michael Ellyett

unread,
Nov 7, 2021, 9:30:48 PM11/7/21
to diagrams.net Q&A
Guys,

Thank you - I got it working.

Now when I try and save the resulting diagram I get this.
image.png
M

Michael Ellyett

unread,
Nov 15, 2021, 12:22:11 AM11/15/21
to diagrams.net Q&A
Thanks.

That worked by the Layout didn't?

Here is the URL with the data
Here is the description
label: %ShortName%
style:label;shape=%shape%;shadow=%shadow%;fillColor=%fill%;strokeColor=%stroke%;fontSize=18;fontColor=%fontColor%;labelBackgroundColor=%labelColor%;textOpacity=90;opacity=%opacity%;spacingLeft=0;align=center;
identity: ID
parent: Parent
parentstyle:shape=rect;autosize=0;expand=0;verticalAlign=bottom;fontSize=25;verticalLabelPosition=top;align=right;labelPosition=center;
ignore: shape,fill,stroke,width,height,fontColor,labelColor,fontStyle,strokeWidth,opacity,shadow,Image
top: top
left: left
width:@width
height: @height
nodespacing: 10
edgespacing: 10
levelspacing: 10
layout: horizontalflow







On Sat, 6 Nov 2021 at 03:55, diagrams.net Q&A <dra...@googlegroups.com> wrote:
Reply all
Reply to author
Forward
0 new messages