# CSV Import From European Country

**URL:** <https://forum.inductiveautomation.com/t/csv-import-from-european-country/35970>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [June 24, 2020, 12:11pm UTC](https://forum.inductiveautomation.com/t/csv-import-from-european-country/35970 "2020-06-24T12:11:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcgheeiv](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mcgheeiv](https://forum.inductiveautomation.com/u/mcgheeiv)\
**Post date:** [June 24, 2020, 12:11pm UTC](https://forum.inductiveautomation.com/t/csv-import-from-european-country/35970/1 "2020-06-24T12:11:56Z")

</div>

A multinational client needs to be able to import CSV files via an Ignition project. All works well when the CSV is created (via Excel) and imported in the US. The issues occur when the CSV is created and imported in Europe. Following is the code I am using to open the file:

```
if system.util.getLocale()[:2] == 'en':
	csv_data = csv.reader(open(path, 'rb'))
else:
	csv_data = csv.reader(open(path, 'rb'), delimiter=';')

```

Any assistance with the following questions is greatly appreciated:

1. Is there a preferred method for dealing with commas used as decimal separators in floating point numbers?
2. Is there a better method for opening the file?

Thanks!  
Mack

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [June 24, 2020, 12:31pm UTC](https://forum.inductiveautomation.com/t/csv-import-from-european-country/35970/2 "2020-06-24T12:31:48Z")

</div>

> [@mcgheeiv](#):
>
> - Is there a preferred method for dealing with commas used as decimal separators in floating point numbers?

Replace them. Even Ignition has (or had) bugs with commas vs points. We have a few projects where any keyboard input event insterting a comma is replaced by a point. As for most projects, they don't need to type long texts, as long as the numbers are correct, it's all we need. We didn't like a motor getting set to 55 Hz when the operator meant 5.5 Hz.

> [@](#):
>
> - Is there a better method for opening the file?

Not really, CSV is very unstandardised. So writing universal code for it is almost impossible. The only thing you can do is try to get to know the special cases (how it's quoted, what delimitors are used, what number and date format, ...) and read the file as text and parse it yourself.

---

<div class="post-metadata">

**Author:** ![martinel3746](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@martinel3746](https://forum.inductiveautomation.com/u/martinel3746)\
**Post date:** [June 24, 2020, 8:39pm UTC](https://forum.inductiveautomation.com/t/csv-import-from-european-country/35970/3 "2020-06-24T20:39:58Z")

</div>

should the 2nd line of your code be:

```auto
csv_data = csv.reader(open(path, 'en'))

```

instead of:

```auto
csv_data = csv.reader(open(path, 'rb'))

```

---

<div class="post-metadata">

**Author:** ![mcgheeiv](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mcgheeiv](https://forum.inductiveautomation.com/u/mcgheeiv)\
**Post date:** [June 24, 2020, 9:04pm UTC](https://forum.inductiveautomation.com/t/csv-import-from-european-country/35970/4 "2020-06-24T21:04:00Z")

</div>

‘en’ is not a valid mode for the open function.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 24, 2020, 9:45pm UTC](https://forum.inductiveautomation.com/t/csv-import-from-european-country/35970/5 "2020-06-24T21:45:43Z")

</div>

If they’re separated by semi-colons, wouldn’t that make them SCSVs? 😁
