# Dynamo CSV Export =\> decimal separator

**URL:** <https://forum.dynamobim.com/t/dynamo-csv-export-decimal-separator/87957>\
**Category:** Lists-Logic\
**Tags:** dynamo, export\
**Created:** [March 29, 2023, 10:28am UTC](https://forum.dynamobim.com/t/dynamo-csv-export-decimal-separator/87957 "2023-03-29T10:28:39Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![VincentL](https://avatars.discourse-cdn.com/v4/letter/v/da6949/32.png) [@VincentL](https://forum.dynamobim.com/u/VincentL)\
**Post date:** [March 29, 2023, 10:28am UTC](https://forum.dynamobim.com/t/dynamo-csv-export-decimal-separator/87957/1 "2023-03-29T10:28:39Z")

</div>

Hi,

I need to export number lists in CSV format (separator = comma). When exporting with the node data.exportCSV, the comma is also used to separate the decimals… Big problem !  
Is it possible to use points as a decimal separator?

Thanks !

Vincent

 ![capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/c/bcb98e069f624df28886d6201a58ec206e302b5f.png)

---

<div class="post-metadata">

**Author:** ![GavinNicholls](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gavinnicholls/32/190442_2.png) [@GavinNicholls](https://forum.dynamobim.com/u/GavinNicholls)\
**Post date:** [March 29, 2023, 10:58am UTC](https://forum.dynamobim.com/t/dynamo-csv-export-decimal-separator/87957/2 "2023-03-29T10:58:55Z")

</div>

Try making a tsv file instead. String join the datarows with a tab, join those with a linebreak snd then write text.

---

<div class="post-metadata">

**Author:** ![leonard.moelders](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/leonard.moelders/32/108216_2.png) [@leonard.moelders](https://forum.dynamobim.com/u/leonard.moelders)\
**Post date:** [March 29, 2023, 11:01am UTC](https://forum.dynamobim.com/t/dynamo-csv-export-decimal-separator/87957/3 "2023-03-29T11:01:05Z")

</div>

Or simply use the export to excel node:  
In my case the csv is then tab delimited

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

EDIT#1:

Just tried @GavinNicholls 's method and it works. BUT if I use codeblocks for the delimiters it does not work. You really need to use the string node:

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

---

<div class="post-metadata">

**Author:** ![GavinNicholls](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gavinnicholls/32/190442_2.png) [@GavinNicholls](https://forum.dynamobim.com/u/GavinNicholls)\
**Post date:** [March 29, 2023, 12:46pm UTC](https://forum.dynamobim.com/t/dynamo-csv-export-decimal-separator/87957/4 "2023-03-29T12:46:21Z")

</div>

Tsv is generally my goto as some regions use commas as decimals (e.g. france, spain) and it gets around dynamo export issues that are common pre 2022. Commas are also common in text based long form fields such as room descriptions.

---

<div class="post-metadata">

**Author:** ![leonard.moelders](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/leonard.moelders/32/108216_2.png) [@leonard.moelders](https://forum.dynamobim.com/u/leonard.moelders)\
**Post date:** [March 29, 2023, 12:52pm UTC](https://forum.dynamobim.com/t/dynamo-csv-export-decimal-separator/87957/5 "2023-03-29T12:52:20Z")

</div>

My first go is to change the settings in excel, as most programms generate comma delimited csv files and in germany excel’s default setting is , instead of . for decimal values and the delimiter for germany is semicolon by default. I even change the keyboard layout/language to switzerland/suiss because then the comma on my num block is then a point, which makes entering numbers easier for me in dynamo

---

<div class="post-metadata">

**Author:** ![VincentL](https://avatars.discourse-cdn.com/v4/letter/v/da6949/32.png) [@VincentL](https://forum.dynamobim.com/u/VincentL)\
**Post date:** [March 30, 2023, 7:40am UTC](https://forum.dynamobim.com/t/dynamo-csv-export-decimal-separator/87957/6 "2023-03-30T07:40:28Z")

</div>

Thanks a lot for your answers. Indeed I could use another node or do a TSV export…

But I saw that on another PC (here a Windows 10 emulated on MacOS) I don’t have the same problem… So it must be possible to adjust somewhere what is the separator used for the decimals !

An idea ?

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/2/b2d99a1d896b57d1b391cb212ebd3e4366ab9b28.jpeg)

---

<div class="post-metadata">

**Author:** ![GavinNicholls](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gavinnicholls/32/190442_2.png) [@GavinNicholls](https://forum.dynamobim.com/u/GavinNicholls)\
**Post date:** [March 30, 2023, 7:45am UTC](https://forum.dynamobim.com/t/dynamo-csv-export-decimal-separator/87957/7 "2023-03-30T07:45:01Z")

</div>

Its probably a windows region setting. Some countries use commas instead of decimals still (crazy!).

---

<div class="post-metadata">

**Author:** ![leonard.moelders](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/leonard.moelders/32/108216_2.png) [@leonard.moelders](https://forum.dynamobim.com/u/leonard.moelders)\
**Post date:** [March 30, 2023, 8:45am UTC](https://forum.dynamobim.com/t/dynamo-csv-export-decimal-separator/87957/8 "2023-03-30T08:45:41Z")

</div>

I don’t know how deep your knowledge is regarding python, but I’m shure you could build your own Data.ExportCSV node via python like @GavinNicholls did here with exporting data to excel here:

> [@Export data to Excel using Python/Microsoft Interop](https://forum.dynamobim.com/t/export-data-to-excel-using-python-microsoft-interop/76899/10):
>
> Thanks Cyril, this will be very helpful for both learning and potentially integrating into a set of nodes. I’ll look into alternatives such as openpyxml in the short-mid term as well for sure. Appreciate your tips and speedy replies everyone! I have tested it on a machine with repair issues and pleased to report it works. The stitched code from the Python script in Dynamo is below if anyone needs to use it. Beautifully written and easy to use/work with as always Cyril - have just begun making…

If you have a look at the code on github you will see that you should be able to create your own method and replace the “,” with an semicolon “;” or anything you want:

```auto
public static class Data
    {
        /// <summary>
        /// Write a list of lists into a file using a comma-separated values 
        /// format. Outer list represents rows, inner lists represent columns. 
        /// </summary>
        /// <param name="filePath">Path to write to</param>
        /// <param name="data">List of lists to write into CSV</param>
        /// <search>write,text,file</search>
        public static void ExportCSV(string filePath, object[][] data)
        {
            using (var writer = new StreamWriter(DSCore.IO.FileSystem.AbsolutePath(filePath)))
            {
                foreach (var line in data)
                {
                    int count = 0;
                    foreach (var entry in line)
                    {
                        writer.Write(entry);
                        if (++count < line.Length)
                            writer.Write(",");
                    }
                    writer.WriteLine();
                }
            }
        }

```

Source: [Dynamo/src/Libraries/DSOffice/Excel.cs at 1167f83d53a5e327e2f13fbc9fec884bf1d7c6b6 · DynamoDS/Dynamo · GitHub](https://github.com/DynamoDS/Dynamo/blob/1167f83d53a5e327e2f13fbc9fec884bf1d7c6b6/src/Libraries/DSOffice/Excel.cs)

But here ends my knowledge, as I am able to reference/use methods from the api in python, but recreating things like gavin did in the topic mentioned above is above my skill level 🥲

This does not solve your problem of getting commas as a decimal seperator for shure, but at least you can work with the csv then. In excel you could either way use the legacy import of csv’s where you can choose the delimiter or you could create and run a batch-file to replace every comma for a point and then replace every semicolon for a comma.  
If you need a batch file that can do this, I can provide it, as I have already been in need for such a batch file before.

EDIT#1:  
Thanks to ChatGPT this does create a csv with the delimiter you want:

```auto
import clr
import System
clr.AddReference("ProtoGeometry")
clr.AddReference("RevitAPI")
from Autodesk.DesignScript.Geometry import *
from Autodesk.Revit.DB import *
from System.Collections.Generic import List

def export_csv_file(file_path, data, delimiter):
    csv_str = ""
    for row in data:
        for i, val in enumerate(row):
            if i != 0:
                csv_str += delimiter
            csv_str += str(val)
        csv_str += "\n"
    System.IO.File.WriteAllText(file_path, csv_str)
    
""" Example usage
data = [["Name", "Age", "City"], ["John", 25, "New York"], ["Jane", 30, "Paris"], ["Bob", 40, "London"]]
file_path = "C:\\Temp\\data.csv"
delimiter = ";"
"""
data = IN[0]
file_path = IN[1]
delimiter = IN[2]
export_csv_file(file_path, data, delimiter)

```

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

---

<div class="post-metadata">

**Author:** ![GavinNicholls](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gavinnicholls/32/190442_2.png) [@GavinNicholls](https://forum.dynamobim.com/u/GavinNicholls)\
**Post date:** [March 30, 2023, 9:44am UTC](https://forum.dynamobim.com/t/dynamo-csv-export-decimal-separator/87957/9 "2023-03-30T09:44:50Z")

</div>

If you have a list of lists you can make a separated file using string.join with strings @L2 and any separator you want. You can then string join those with a return (enter) and finally use the write file node including desired extension with that as the text.

There is also examples or reading/writing csv using Python here: [csv — CSV File Reading and Writing — Python 3.11.2 documentation](https://docs.python.org/3/library/csv.html)

---

<div class="post-metadata">

**Author:** ![VincentL](https://avatars.discourse-cdn.com/v4/letter/v/da6949/32.png) [@VincentL](https://forum.dynamobim.com/u/VincentL)\
**Post date:** [March 30, 2023, 6:27pm UTC](https://forum.dynamobim.com/t/dynamo-csv-export-decimal-separator/87957/10 "2023-03-30T18:27:16Z")

</div>

Thank you very much again for all these detailed answers.  
Indeed, Python or the string.join node are also good solutions…  
But I will deepen this “windows region setting” : I have to teach in different schools with differents settings and I would like to understand why the different machines do not behave the same way!

---

<div class="post-metadata">

**Author:** ![VincentL](https://avatars.discourse-cdn.com/v4/letter/v/da6949/32.png) [@VincentL](https://forum.dynamobim.com/u/VincentL)\
**Post date:** [March 31, 2023, 6:08am UTC](https://forum.dynamobim.com/t/dynamo-csv-export-decimal-separator/87957/11 "2023-03-31T06:08:54Z")

</div>

Confirmation : it’s the “windows region setting” !

Thank you for your help !
