# Format CSV to 2 decimal points

**URL:** <https://forum.inductiveautomation.com/t/format-csv-to-2-decimal-points/96990>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [October 8, 2024, 7:21pm UTC](https://forum.inductiveautomation.com/t/format-csv-to-2-decimal-points/96990 "2024-10-08T19:21:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![scadafan](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@scadafan](https://forum.inductiveautomation.com/u/scadafan)\
**Post date:** [October 8, 2024, 7:21pm UTC](https://forum.inductiveautomation.com/t/format-csv-to-2-decimal-points/96990/1 "2024-10-08T19:21:23Z")

</div>

Hey everyone,

I am using:

`system.tag.queryTagHistory(paths=tagPaths, startDate=previousRunStartTime, endDate=RunEndTime, returnSize=3600, aggregationMode="LastValue")`

to pull data for CSV

It works great but I when it sends to the csv all values that are floats have 7+ decimal points I would like to narrow it down to just 2 or 3. Is there a simple way of doing that within Ignition or is my only option to script it?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 8, 2024, 7:56pm UTC](https://forum.inductiveautomation.com/t/format-csv-to-2-decimal-points/96990/2 "2024-10-08T19:56:37Z")

</div>

Tip: the first two or three lines of your block of code aren't formatted properly and so have lost their indentation. Please see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [October 8, 2024, 8:00pm UTC](https://forum.inductiveautomation.com/t/format-csv-to-2-decimal-points/96990/3 "2024-10-08T20:00:03Z")

</div>

An easy way would be to use a function kinda like this one:

```python
def round_2(v):
	try:
		return round(v, 2)
	except:
		return v

```

and pass the value to this function:

```python
values = [round_2(history.getValueAt(row, col)) for col in range(1, history.getColumnCount())]

```

edit:  
I'm using `try` here instead of something like `if isinstance(v, float)` just in case the values are not actually `float` but some other type/wrapper. If you can confirm the type, it's maybe better to just check it.

---

<div class="post-metadata">

**Author:** ![scadafan](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@scadafan](https://forum.inductiveautomation.com/u/scadafan)\
**Post date:** [October 8, 2024, 8:12pm UTC](https://forum.inductiveautomation.com/t/format-csv-to-2-decimal-points/96990/4 "2024-10-08T20:12:54Z")

</div>

yes thank you I did something similar to this
