# \[Perspective\] Read CSV with Comma as a Decimal Separator for Floats

**URL:** <https://forum.inductiveautomation.com/t/perspective-read-csv-with-comma-as-a-decimal-separator-for-floats/56833>\
**Category:** Ignition\
**Tags:** perspective, ignition81, scripting\
**Created:** [March 4, 2022, 11:16am UTC](https://forum.inductiveautomation.com/t/perspective-read-csv-with-comma-as-a-decimal-separator-for-floats/56833 "2022-03-04T11:16:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Davide3i](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/davide3i/32/27811_2.png) [@Davide3i](https://forum.inductiveautomation.com/u/Davide3i)\
**Post date:** [March 4, 2022, 11:16am UTC](https://forum.inductiveautomation.com/t/perspective-read-csv-with-comma-as-a-decimal-separator-for-floats/56833/1 "2022-03-04T11:16:29Z")

</div>

Hello.  
I’m trying to correctly import some data from a CSV file with has numbers with commas as decimal separators. At the moment this is my code, but I’m trying to understand how to use _locale_ to achieve my goal and correctly convert commas to dots. Any hints?

```auto
	import csv
	from StringIO import StringIO
	import locale
	
	reader = csv.reader(StringIO(event.file.getString("UTF-8")), delimiter=";")
	header = reader.next()
	self.view.custom.table.data = system.dataset.toDataSet(header, list(reader))

```

A CSV row is formatted like this:

```auto
recipe_name;cm_type;cm_name;motion_function;param_name;tag_path;value
Medium;AX;AQ_AP;PS;MotorRevNo;[default]CM/AX/AQ_AP/Par/MotorRevNo;2,00

```

---

<div class="post-metadata">

**Author:** ![Davide3i](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/davide3i/32/27811_2.png) [@Davide3i](https://forum.inductiveautomation.com/u/Davide3i)\
**Post date:** [March 4, 2022, 12:31pm UTC](https://forum.inductiveautomation.com/t/perspective-read-csv-with-comma-as-a-decimal-separator-for-floats/56833/2 "2022-03-04T12:31:07Z")

</div>

I’ve solved this using:

```auto
reader = csv.reader(StringIO(event.file.getString("UTF-8")), delimiter=";")
l = []

for row in reader:
	item = []
	for column in row: item.append(column.replace(',', '.'))
	l.append(item)

self.view.custom.table.data = system.dataset.toDataSet(header, l)

```

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [March 4, 2022, 1:00pm UTC](https://forum.inductiveautomation.com/t/perspective-read-csv-with-comma-as-a-decimal-separator-for-floats/56833/3 "2022-03-04T13:00:09Z")

</div>

Just want to point out that you’re asking for issues with this code:

1. Never use built-in types for variable names
2. At least in the script you have shown, list isn’t defined.

Something like this is better:

```python
reader = csv.reader(StringIO(event.file.getString("UTF-8")),delimiter=";")

convertedData =[[column.replace(',','.') for column in row] for row in reader]
self.view.custom.table.data = system.dataset.toDataSet(header,convertedData)

```
