# Draw a polygon by csv-file

**URL:** <https://forum.dynamobim.com/t/draw-a-polygon-by-csv-file/27733>\
**Category:** Geometry\
**Created:** [October 27, 2018, 10:38am UTC](https://forum.dynamobim.com/t/draw-a-polygon-by-csv-file/27733 "2018-10-27T10:38:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![cad.sl](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/cad.sl/32/59755_2.png) [@cad.sl](https://forum.dynamobim.com/u/cad.sl)\
**Post date:** [October 27, 2018, 10:38am UTC](https://forum.dynamobim.com/t/draw-a-polygon-by-csv-file/27733/1 "2018-10-27T10:38:43Z")

</div>

Hi all, I’m an absolute beginner in dynamo, and hope to find here a little help.  
I would like to draw a polygon with coordinates from a text-file.  
The coordinates have only x and y values (decimal values and comma separated).

Importing the file gives me two lists though. And the decimal point disappears.

 ![grafik](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/6/d6b06c32695731a40fcfb36bd5431b0cd2109df2.png)  
Any help appreciatetd.

---

<div class="post-metadata">

**Author:** ![lucamanzoni](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/lucamanzoni/32/56718_2.png) [@lucamanzoni](https://forum.dynamobim.com/u/lucamanzoni)\
**Post date:** [October 27, 2018, 2:48pm UTC](https://forum.dynamobim.com/t/draw-a-polygon-by-csv-file/27733/2 "2018-10-27T14:48:51Z")

</div>

Hi,  
for your import problem you can try with [Division](http://dictionary.dynamobim.com/#/Operators/Action/Division) node, dividing everything by 1000. Otherwise you can try with Excel to see if it recognizes the decimals.

Moreover you need to create points to feed in your Polygon.ByPoints node (that’s why is yellow, you are connecting numbers instead of points). You can simply use [Point.ByCoordinates](http://dictionary.dynamobim.com/#/Geometry/Point/Create/ByCoordinates(x_double-y_double-z_double)), taking input X and Y from your list of imported coordinates.

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [October 27, 2018, 6:19pm UTC](https://forum.dynamobim.com/t/draw-a-polygon-by-csv-file/27733/3 "2018-10-27T18:19:14Z")

</div>

Instead of importing the CSV, use a File.ReadText node. You’ll have to parse the data out with some strings nodes but that’s a good learning exercise.

String.Split with a split string value of a string node containing only a new line character in it. Then String.Split with a , as your separating value. After that you’ll have to convert the strings to numbers.

From there you should be on your way.

---

<div class="post-metadata">

**Author:** ![cad.sl](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/cad.sl/32/59755_2.png) [@cad.sl](https://forum.dynamobim.com/u/cad.sl)\
**Post date:** [October 28, 2018, 9:59am UTC](https://forum.dynamobim.com/t/draw-a-polygon-by-csv-file/27733/4 "2018-10-28T09:59:49Z")

</div>

Thank you Luca and Jacob very much!  
Your advices were very helpful for me, I made some progress 😄

I could convert the text-file into a number list. But it’s nested. Is that a problem?  
And there is still a problem, with the drawing-part:

 ![grafik](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/4/a4a35646b31e7c6e948cfb412e04e68cefd27e1f.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [October 28, 2018, 3:43pm UTC](https://forum.dynamobim.com/t/draw-a-polygon-by-csv-file/27733/5 "2018-10-28T15:43:59Z")

</div>

You need to _Transpose_ your list so you have X values in one list and Y values in the other. Then you will need a _First Item_ and a _Last Item_ node to pull the X values and Y values out of the list. After that you will want to make a _Point By Coordinates_, making sure you choose a method with only X and Y values. Then you will want to make a _Polycurve By Points_ to complete the effort.

After all of that, go do the Dynamo Primer in its entirety. Skip nothing, even if you think you’ll never use it. The excercises are designed to teach concepts, not outcomes. While you may not have to place solar panels on a roof, you’ll have to utilize cross product lacing often.

-jacob

---

<div class="post-metadata">

**Author:** ![cad.sl](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/cad.sl/32/59755_2.png) [@cad.sl](https://forum.dynamobim.com/u/cad.sl)\
**Post date:** [October 29, 2018, 9:54pm UTC](https://forum.dynamobim.com/t/draw-a-polygon-by-csv-file/27733/6 "2018-10-29T21:54:18Z")

</div>

finally it works - thank you very much!  
this is, how it looks like:

 ![grafik](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/3/e350e5dc0a649a3b77db76c6e61ad4a6ffd3d119.png)

---

<div class="post-metadata">

**Author:** ![salvatoredragotta](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/salvatoredragotta/32/10078_2.png) [@salvatoredragotta](https://forum.dynamobim.com/u/salvatoredragotta)\
**Post date:** [November 1, 2018, 1:31am UTC](https://forum.dynamobim.com/t/draw-a-polygon-by-csv-file/27733/7 "2018-11-01T01:31:58Z")

</div>

Does anyone know why String.Split produces a different out with the “;” in a Code block?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/d/ddd7d40a4ef098fb1fce63464c662dbc84dcbcd0.png)

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [November 1, 2018, 2:10am UTC](https://forum.dynamobim.com/t/draw-a-polygon-by-csv-file/27733/8 "2018-11-01T02:10:59Z")

</div>

Maybe it is a special character? Try “\;”

Edit: Trying that throws up an error. Must just be an issue with ;
